summaryrefslogtreecommitdiffstats
path: root/petascope/src/petascope/wcps/server/core/SliceCoverageExpr.java
diff options
context:
space:
mode:
Diffstat (limited to 'petascope/src/petascope/wcps/server/core/SliceCoverageExpr.java')
-rw-r--r--petascope/src/petascope/wcps/server/core/SliceCoverageExpr.java222
1 files changed, 110 insertions, 112 deletions
diff --git a/petascope/src/petascope/wcps/server/core/SliceCoverageExpr.java b/petascope/src/petascope/wcps/server/core/SliceCoverageExpr.java
index ca6c478..42d1370 100644
--- a/petascope/src/petascope/wcps/server/core/SliceCoverageExpr.java
+++ b/petascope/src/petascope/wcps/server/core/SliceCoverageExpr.java
@@ -14,119 +14,117 @@
* You should have received a copy of the GNU General Public License
* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
*
- * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
- rasdaman GmbH.
+ * Copyright 2003 - 2010 Peter Baumann / rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
*/
-package petascope.wcps.server.core;
-
-import petascope.wcps.server.exceptions.InvalidCrsException;
-import petascope.wcps.server.exceptions.WCPSException;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.w3c.dom.Node;
-
-public class SliceCoverageExpr implements IRasNode, ICoverageInfo {
-
- private List<DimensionPointElement> axisList;
- private CoverageExpr coverageExprType;
- private CoverageInfo coverageInfo = null;
- private String[] dim;
- private DimensionPointElement elem;
- private int dims;
-
- public SliceCoverageExpr(Node node, XmlQuery xq) throws WCPSException, InvalidCrsException {
- Node child = node.getFirstChild();
- String nodeName;
-
- axisList = new ArrayList<DimensionPointElement>();
-
- while (child != null) {
- nodeName = child.getNodeName();
-
- if (nodeName.equals("#text")) {
- child = child.getNextSibling();
- continue;
- }
-
- try {
- System.err.println("Trying out an CoverageExprType group...");
- coverageExprType = new CoverageExpr(child, xq);
- coverageInfo = coverageExprType.getCoverageInfo();
- child = child.getNextSibling();
- continue;
- } catch (WCPSException e) {
- System.err.println("This was no CoverageExprType: " + nodeName);
- }
-
- try {
- // Start a new axis and save it
- elem = new DimensionPointElement(child, xq);
- axisList.add(elem);
- child = elem.getNextNode();
- continue;
- } catch (WCPSException e) {
- System.err.println("This was no Dimension Point ELement: " + child.getNodeName());
- }
-
- // else unknown element
- throw new WCPSException("Unknown node for TrimCoverage expression:" + child.getNodeName());
- }
-
- dims = coverageInfo.getNumDimensions();
- dim = new String[dims];
-
- for (int j = 0; j < dims; ++j) {
- dim[j] = "*:*";
- }
-
- Iterator<DimensionPointElement> i = axisList.iterator();
- DimensionPointElement axis;
- int axisId;
- int slicingPosInt;
- String slicingPosStr;
-
- while (i.hasNext()) {
- axis = i.next();
- /* TODO: BUG: This searches the axis types list using name, not type */
- axisId = coverageInfo.getDomainIndexByName(axis.getAxisName());
- slicingPosStr = axis.getSlicingPosition();
- dim[axisId] = slicingPosStr;
- // Slicing position can be a constant number or a variable reference
- try {
- slicingPosInt = Integer.parseInt(slicingPosStr);
- } catch (NumberFormatException e) {
- slicingPosInt = 1;
- }
- coverageInfo.setCellDimension(
- axisId,
- new CellDomainElement(
- BigInteger.valueOf(slicingPosInt), BigInteger.valueOf(slicingPosInt)));
-
- }
-
- }
-
- public CoverageInfo getCoverageInfo() {
- return coverageInfo;
- }
-
- public String toRasQL() {
- String result = "(" + coverageExprType.toRasQL() + ") [";
-
- for (int j = 0; j < dims; ++j) {
- if (j > 0) {
- result += ",";
- }
-
- result += dim[j];
- }
-
- result += "]";
- return result;
- }
-}
+package petascope.wcps.server.core;
+
+import petascope.exceptions.WCPSException;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.w3c.dom.Node;
+
+public class SliceCoverageExpr implements IRasNode, ICoverageInfo {
+
+ private List<DimensionPointElement> axisList;
+ private CoverageExpr coverageExprType;
+ private CoverageInfo coverageInfo = null;
+ private String[] dim;
+ private DimensionPointElement elem;
+ private int dims;
+
+ public SliceCoverageExpr(Node node, XmlQuery xq) throws WCPSException {
+ Node child = node.getFirstChild();
+ String nodeName;
+
+ axisList = new ArrayList<DimensionPointElement>();
+
+ while (child != null) {
+ nodeName = child.getNodeName();
+
+ if (nodeName.equals("#text")) {
+ child = child.getNextSibling();
+ continue;
+ }
+
+ try {
+ System.err.println("Trying out an CoverageExprType group...");
+ coverageExprType = new CoverageExpr(child, xq);
+ coverageInfo = coverageExprType.getCoverageInfo();
+ child = child.getNextSibling();
+ continue;
+ } catch (WCPSException e) {
+ System.err.println("This was no CoverageExprType: " + nodeName);
+ }
+
+ try {
+ // Start a new axis and save it
+ elem = new DimensionPointElement(child, xq);
+ axisList.add(elem);
+ child = elem.getNextNode();
+ continue;
+ } catch (WCPSException e) {
+ System.err.println("This was no Dimension Point ELement: " + child.getNodeName());
+ }
+
+ // else unknown element
+ throw new WCPSException("Unknown node for TrimCoverage expression:" + child.getNodeName());
+ }
+
+ dims = coverageInfo.getNumDimensions();
+ dim = new String[dims];
+
+ for (int j = 0; j < dims; ++j) {
+ dim[j] = "*:*";
+ }
+
+ Iterator<DimensionPointElement> i = axisList.iterator();
+ DimensionPointElement axis;
+ int axisId;
+ int slicingPosInt;
+ String slicingPosStr;
+
+ while (i.hasNext()) {
+ axis = i.next();
+ /* TODO: BUG: This searches the axis types list using name, not type */
+ axisId = coverageInfo.getDomainIndexByName(axis.getAxisName());
+ slicingPosStr = axis.getSlicingPosition();
+ dim[axisId] = slicingPosStr;
+ // Slicing position can be a constant number or a variable reference
+ try {
+ slicingPosInt = Integer.parseInt(slicingPosStr);
+ } catch (NumberFormatException e) {
+ slicingPosInt = 1;
+ }
+ coverageInfo.setCellDimension(
+ axisId,
+ new CellDomainElement(
+ BigInteger.valueOf(slicingPosInt), BigInteger.valueOf(slicingPosInt)));
+
+ }
+
+ }
+
+ public CoverageInfo getCoverageInfo() {
+ return coverageInfo;
+ }
+
+ public String toRasQL() {
+ String result = "(" + coverageExprType.toRasQL() + ") [";
+
+ for (int j = 0; j < dims; ++j) {
+ if (j > 0) {
+ result += ",";
+ }
+
+ result += dim[j];
+ }
+
+ result += "]";
+ return result;
+ }
+}