Updating the JTS (Java Topology Suite) JARs

From gvSIG CE Wiki

Jump to: navigation, search

The Java Topology Suite (JTS) is a collection of highly advanced Java classes for handling topology in vector data. Not only gvSIG, but also SEXTANTE depends on it. Thus, it is important to keep the JTS updated.

A version of JTS must be included in the gvSIG CE project "libFMap". The current version we use for gvSIG CE is JTS 1.12.

In case an update is required:

  1. Download the latest JTS from its SF.net project page (go to "Files"). The download is a ZIP archive that contains sources as well as pre-compiled Java classes.
  2. Unzip the downloaded file.
  3. In the folder lib, you will find the two main JTS JAR files, "jts-n.nn.jar" and "jtsio-n.nn.jar".
  4. You now have to find a tool that can update the contens of JAR files (e.g. Midnight Commander under Linux).
  5. Copy the oracle and sde class folders from "jtsio-n.nn.jar" into the corresponding io class directory in "jts-n.nn.jar".
  6. In your copy of the gvSIG CE SVN sources, find the old copies of "jts-m.mm.jar" in libFMap/lib and libFMap/dist/lib. Replace them with the new "jts-n.nn.jar".
  7. Edit libFMap/build.xml. Find the lines below and insert the new JTS version numbers:
 <rename dest="${dist}/lib/jts-1.12_gvSIG.jar" src="${dist}/lib/jts-1.12.jar"/>
 <jar jarfile="${dist}/lib/jts-1.12_gvSIG.jar" basedir="${build}" update="yes" [..]

Explanation: libFMap makes a few modifications to the JTS snapping classes. These are done to make the snapping work better. Since very little has happened to the snapping code in recent JTS updates, this does not seem to be a problem. The modified classes are then copied back into the JTS JAR file. This is why it is important to keep the build.xml file updated. The result will be a JTS JAR with a "_gvSIG" prefix in its name to indicate that it has modified content. This is the JAR that will be used by gvSIG (and SEXTANTE) at runtime.

JTS Dependencies: After updating the JTS, you have to go through all projects in your Eclipse workspace that depend on it and update the library path.

  1. Choose "Properties" from the project's context menu, then "Java Build Path".
  2. Switch to the "Libraries" page. You will see the outdated entry marked as an error.
  3. Select it and click "Edit..." to browse for the new JTS JAR.

Note: Check to make sure that that the path to JTS-n-nn.jar is relative to your workspace. Do not save commit paths back to the SVN! In case there are problems with this, it may be easier to temporarily exit Eclipse and edit the Java .classpath files manually for each project! After restarting Eclipse, you might have to Refresh the folders of all affected projects, before you will be able to commit the updated classpaths to the SVN.

E.g., for JTS 1.12, the classpath entry for "libFMap" should read:

 <classpathentry kind="lib" path="lib/jts-1.12.jar"/>

For all other projects (see list below), it should read:

 <classpathentry kind="lib" path="/libFMap/lib/jts-1.12.jar"/>

The projects that will need updating are:

  • appgvSIG
  • appCatalogAndGazetteerClient
  • extAnnotations
  • extArcims
  • extCAD
  • extDerivedGeometries
  • extExpressionField
  • extGeoProcessing
  • extGeoProcessingExtensions
  • extGPE-gvSIG
  • extGraph
  • extJDBC
  • extMeasureGeometry
  • extOracleSpatial
  • extQuickInfo
  • extSelectionTools
  • extSymbology
  • extTopology
  • libFMap
  • libGDBMS
  • libGeometries
  • libTopology

To finish up, edit appgvSIG/config/dependencies.xml, find the lines below and update the JTS version name, as well: