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

uk.ac.rdg.resc.edal.graphics.style.sld.FloatSLDInterpolateFunction 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.util.ArrayList;

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

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

import uk.ac.rdg.resc.edal.graphics.style.InterpolationPoint;

public class FloatSLDInterpolateFunction extends
		AbstractSLDInterpolateFunction {

	public FloatSLDInterpolateFunction(XPath xPath, Node function) throws SLDException {
		super(xPath, function);
		try {
			// get the fallback value
			this.fallbackValue = parseFloatFallbackValue();
			
			// get list of data points
			NodeList pointNodes = parseInterpolationPoints();
			
			// parse into an ArrayList
			interpolationPoints = new ArrayList>();
			for (int j = 0; j < pointNodes.getLength(); j++) {
				Node pointNode = pointNodes.item(j);
				Node dataNode = (Node) xPath.evaluate(
						"./se:Data", pointNode, XPathConstants.NODE);
				if (dataNode == null) {
					throw new SLDException("Each interpolation point must contain a data element.");
				}
				Node valueNode = (Node) xPath.evaluate(
						"./se:Value", pointNode, XPathConstants.NODE);
				if (valueNode == null) {
					throw new SLDException("Each interpolation point must contain a value element.");
				}
				interpolationPoints.add(new InterpolationPoint(
						Float.parseFloat(dataNode.getTextContent().trim()),
						Float.parseFloat(valueNode.getTextContent().trim())));
			}
		} catch(Exception e) {
			throw new SLDException(e);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy