/*
 * This file is part of Mapyrus, software for plotting maps.
 * Copyright (C) 2003 Simon Chenery.
 *
 * Mapyrus 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 of the License, or
 * (at your option) any later version.
 *
 * Mapyrus 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Mapyrus; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

/*
 * @(#) $Id$
 */
package org.mapyrus.function;

import java.util.HashMap;

import org.mapyrus.MapyrusException;

/**
 * Manages all available functions.  Provides function name
 * lookup function.
 */
public class FunctionTable
{
	static HashMap mFunctions = new HashMap();

	/*
	 * Load all internal functions and any additional functions defined by user.
	 */
	static
	{
		Function f;

		f = new Abs();
		mFunctions.put(f.getName(), f);

		f = new Ceil();
		mFunctions.put(f.getName(), f);

		f = new Cos();
		mFunctions.put(f.getName(), f);

		f = new Floor();
		mFunctions.put(f.getName(), f);

		f = new Length();
		mFunctions.put(f.getName(), f);

		f = new Log10();
		mFunctions.put(f.getName(), f);

		f = new Match();
		mFunctions.put(f.getName(), f);

		f = new Max();
		mFunctions.put(f.getName(), f);

		f = new Min();
		mFunctions.put(f.getName(), f);

		f = new Pow();
		mFunctions.put(f.getName(), f);

		f = new Random();
		mFunctions.put(f.getName(), f);

		f = new Replace();
		mFunctions.put(f.getName(), f);

		f = new Round();
		mFunctions.put(f.getName(), f);
		
		f = new Sin();
		mFunctions.put(f.getName(), f);
		
		f = new Split();
		mFunctions.put(f.getName(), f);
		
		f = new Sqrt();
		mFunctions.put(f.getName(), f);
		
		f = new Stringwidth();
		mFunctions.put(f.getName(), f);
		
		f = new Substr();
		mFunctions.put(f.getName(), f);
		
		f = new Tan();
		mFunctions.put(f.getName(), f);
		
		f = new Tempname();
		mFunctions.put(f.getName(), f);
	};

	/**
	 * Lookup function from name and return object
	 * @param name name of function to lookup.
	 * @return object for evaluating this function, or null if not found.
	 */
	public static Function getFunction(String funcName) throws MapyrusException
	{
		Function retval = (Function)(mFunctions.get(funcName));
		return(retval);
	}
}

@@ -1680,32 +1680,89 @@
 getName(), f);%0A%0A
+%09%09f = new Parsewkt();%0A%09%09mFunctions.put(f.getName(), f);%0A%0A
 %09%09f = new Pow();
@@ -2357,16 +2357,422 @@
 e(), f);
+%0A%0A%09%09try%0A%09%09%7B%0A%09%09%09/*%0A%09%09%09 * Java Topology Suite functions are only available if the%0A%09%09%09 * JTS JAR file is available in the classpath.%0A%09%09%09 */%0A%09%09%09f = new Buffer();%0A%09%09%09mFunctions.put(f.getName(), f);%0A%09%09%7D%0A%09%09catch (NoClassDefFoundError e)%0A%09%09%7B%0A%09%09%09/*%0A%09%09%09 * Add dummy placeholder functions instead.%0A%09%09%09 * They'll fail if they are ever called though.%0A%09%09%09 */%0A%09%09%09mFunctions.put(%22buffer%22, new DummyFunction(%22buffer%22));%0A%09%09%7D
 %0A%09%7D;%0A%0A%09/

Add parsewkt(), buffer() from JTS library.