TAL C++ source code

Current version 1.2 (21 Aug. 02)

What is it?

    I am releasing the object-oriented C++ source code for Texture AutoLookup (TAL). With TAL, you can determine the soil texture classes based on any given soil classification scheme. Because the code is object-oriented, you can easily use or inherit TAL classes in your own programl.

What's new in version 1.2?

  • Now supports axes names. Added three pairs of "get/set" functions to access the names of the x-, y- and z-axis.

  • Changed the protected member functions ToGPC() and FromGPC() to virtual functions so that users can customise the type of polygon required. As it is, TAL uses polygons that have no holes and only one contour.

What's new in version 1.1?

  • Added new functions in class polygon: Centroid(), Difference(), XOR(), and Union().

  • Changed RangeToPolygon() function in class soiltex from a protected member function to a public member function.

  • Modified the GPC source file gpc.c to remove the compiler warnings

  • Extra error checking, and some codes rewritten to be more efficient.

Learning about TAL

    TAL has two classes:

    The above two classes use the following helper or support structures and functions:

    Examples of TAL classes in action, and how to define soil schemes:


    If you are not planning to subscribe to TAL's mailing list, I would greatly appreciate it if you would email to me that you are downloading TAL. Lots of people have downloaded TAL without informing me; is this too much to ask for a free cool product? email me

    Please let me know the following information: 1) name, 2) profession, 3) organisation, and 4) how you heard about TAL. These information are for my personal reference only; they will not be shared or distributed.

email cbsteh@yahoo.com

TAL C++ Source code
Ver. 1.2 download talcpp12.zip (25 k)

    The file is compressed as a .zip archive. You can use Winzip or Pkzip programs to decompress the file. Once decompressed, you should have the following eight files:

soiltex.h, soiltex.cpp
polygon.h, polygon.cpp
futil.h, futil.cpp
gpc.h, gpc.c

where the last two files, gpc.h and gpc.c, are the GPC (Generic Polygon Clipper) library written in C by Alan Murta, Advanced Interfaces Group, University of Manchester.

Data files for soil classification schemes
  1. USDA (U.S. Dept. of Agric.)
  2. UK (England and Wales)
  3. Canada
  4. International
  5. India
  6. ISSS (Intl. Soil Sci. Soc.)
  7. Switzerland
  8. INEAC (Inst. Nat. pour L'Etude Agron. du Congo)
  9. New Zealand
  10. FAO (Food and Agric. Org.)
  11. AISNE (France)
  12. German schemes (contributed by Dr. Detlef Deumlich)
  13. Shepard's (1954) proposed scheme (contributed by Simon Six)
downloadschemes.zip (9k)

     Let me know if you have a soil classification scheme not listed here; I will add it!

Conditions of Use

    TAL source code is free for non-commercial use. It may be copied, modified, and redistributed provided that credit is given to the author somewhere in your program documentation. TAL source code is provided 'as is' without any warranty, implied or expressed.


    Compile all source files as C++ files except the gpc.c which must be compiled as a C file.

    I have tested compiling TAL code in Windows using two compilers: Microsoft Visual C++ 5.0 SP3, and Borland C++ 5.5. I do not expect problems if you use other modern C++ compilers or in other operating systems (OS). TAL code has no hardware- or OS-specific instructions, and it is written to conform to ANSI/ISO C++ standard.

    Nevertheless, you may get some compiler warnings (e.g., warnings on unreachable code or variable unused) while compiling the GPC file gpc.c (which is not written by me!). These warnings, however, are harmless and can be safely ignored.

Quick and dirty compilation

    For the Microsoft C++ 5.0 compiler, this is one way you can compile TAL files from the command line:

CL /I"c:\devstudio\vc\include" /GX /c gpc.c *.cpp

and for the Borland C++ 5.5 compiler:

BCC32 -I"c:\bcc55\include" -P- -c gpc.c *.cpp

Modify the above path location for your compiler and include header files, as needed.

Suggestions, comments, feedback

    Please let me know if you have trouble using TAL, or if you have any suggestions or comments.

- Christopher Teh Boon Sung

TAL Home | Code Main Page | email
  updated: 22-Aug-2002