All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.ac.rdg.resc.edal.graphics.style.sld.SLDFunction2DParser Maven / Gradle / Ivy

There is a newer version: 1.5.3
Show newest version
package uk.ac.rdg.resc.edal.graphics.style.sld;

import java.awt.Color;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class SLDFunction2DParser {

	public static SLDFunction parseColorSLDFunction2D(XPath xPath, Node node)
			throws SLDException {
		try {
			// Get lists of the functions
			NodeList categorize2DFunctions = (NodeList) xPath.evaluate(
					"./resc:Categorize2D", node, XPathConstants.NODESET);
			
			// check that there is exactly one function and parse it if so
			if (categorize2DFunctions.getLength() == 1) {
				return new ColorSLDCategorize2DFunction(xPath, categorize2DFunctions.item(0));
			} else {
				throw new SLDException("A single function (Categorize2D) was expected.");
			}
		} catch (Exception e) {
			throw new SLDException(e);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy