jwo.landserf.process
Class SimplifyThread

java.lang.Object
  extended by java.lang.Thread
      extended by jwo.landserf.process.LSThread
          extended by jwo.landserf.process.SimplifyThread
All Implemented Interfaces:
Runnable, Scriptable, JWInterruptionListener

public class SimplifyThread
extends LSThread
implements Scriptable

Allows the lines in the primary vector map to be simplified using the Douglas-Peucker line simplification algorithm.

Version:
2.3, 23rd October, 2007.
Author:
Jo Wood

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SimplifyThread(GISFrame gisFrame)
          Creates an object ready for simplification of a vector map but does not perform the simplification.
SimplifyThread(GISFrame gisFrame, float tolerance)
          Creates an object that will simplify a vector map.
 
Method Summary
 boolean doCommand(LSCommand command)
          Simplifies the vector map specified in the given scripting parameters.
 void doProcessing()
          Simplifies the lines in the primary vector map.
 LSCommand getCommand()
          Reports the syntax required to allow vector map to be simplified via a scripting command.
 GISFrame getGISFrame()
          Retrieves the GISFrame that can be used for storing multiple spatial objects and messages.
 Object getReturnedObject()
          Returns the newly simplified vector map.
 VectorMap getSimplifiedVectorMap()
          Retrieves the simplified vector map.
static GISVector simplify(GISVector gisVect, float tolerance)
          Creates a simplified version of the given GISVector object.
 
Methods inherited from class jwo.landserf.process.LSThread
checkStoppedThread, interruptionRequested, resetTimer, run, setErrorMessage, setFinalMessage, setMessage
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimplifyThread

public SimplifyThread(GISFrame gisFrame)
Creates an object ready for simplification of a vector map but does not perform the simplification. This is primarily used for simplifying vector maps via the scripting interface.

Parameters:
gisFrame - Frame holding spatial objects and in which to report results.

SimplifyThread

public SimplifyThread(GISFrame gisFrame,
                      float tolerance)
Creates an object that will simplify a vector map.

Parameters:
gisFrame - Frame holding spatial objects and in which to report results.
tolerance - Tolerance threshold distance measured in the map units of the primary vector.
Method Detail

doProcessing

public void doProcessing()
Simplifies the lines in the primary vector map. The resulting vector map is added to the GISFrame provided to the constructor and selected as the primary vector map. To retrieve it either call getSimplifiedVectorMap() from this class or call gisFrame.getVectorMap1();.

Note that this method will be called automatically if this is run as a threaded process (e.g. mySimplifyThread.start()). Alternatively it can be called directly as a non-threaded process.

Specified by:
doProcessing in class LSThread
See Also:
GISFrame

getCommand

public LSCommand getCommand()
Reports the syntax required to allow vector map to be simplified via a scripting command.

Specified by:
getCommand in interface Scriptable
Returns:
Command syntax.

doCommand

public boolean doCommand(LSCommand command)
Simplifies the vector map specified in the given scripting parameters.

Specified by:
doCommand in interface Scriptable
Parameters:
command - Command containing parameter values.
Returns:
True if objects simplified successfully. If false, the details of the problem are reported to the gisFrame.

getReturnedObject

public Object getReturnedObject()
Returns the newly simplified vector map. This is identical to getSimplifiedVectorMap except that it is compatible with the scriptable interface. If command has yet to be issued this will return null.

Specified by:
getReturnedObject in interface Scriptable
Returns:
New spatial object or null if problems simplifying or command has not yet been issued.

getGISFrame

public GISFrame getGISFrame()
Retrieves the GISFrame that can be used for storing multiple spatial objects and messages.

Specified by:
getGISFrame in interface Scriptable
Returns:
GISFrame storing spatial objects and messages.

simplify

public static GISVector simplify(GISVector gisVect,
                                 float tolerance)
Creates a simplified version of the given GISVector object. Uses Douglas-Peucker simplifcation using the given tolerance value. The greater the tolerance, the greater the simplification.

Parameters:
gisVect - Vector object to simplify.
tolerance - Douglas-Peucker tolerance (in spatial units).
Returns:
new Vector object containing simplified geometry or null if simplified version eliminates object entirely.

getSimplifiedVectorMap

public VectorMap getSimplifiedVectorMap()
Retrieves the simplified vector map.

Returns:
New vector map with simplified objects, or null if problems or simplification is yet to take place.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009