summaryrefslogtreecommitdiffstats
path: root/petascope/src/petascope/wcps/server/core/TrimCoverageExpr.java
diff options
context:
space:
mode:
Diffstat (limited to 'petascope/src/petascope/wcps/server/core/TrimCoverageExpr.java')
-rw-r--r--petascope/src/petascope/wcps/server/core/TrimCoverageExpr.java224
1 files changed, 110 insertions, 114 deletions
diff --git a/petascope/src/petascope/wcps/server/core/TrimCoverageExpr.java b/petascope/src/petascope/wcps/server/core/TrimCoverageExpr.java
index 889780a..4ecb536 100644
--- a/petascope/src/petascope/wcps/server/core/TrimCoverageExpr.java
+++ b/petascope/src/petascope/wcps/server/core/TrimCoverageExpr.java
@@ -14,121 +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 org.w3c.dom.*;
-
-import java.math.BigInteger;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-public class TrimCoverageExpr implements IRasNode, ICoverageInfo {
-
- private List<DimensionIntervalElement> axisList;
- private CoverageExpr coverageExprType;
- private CoverageInfo coverageInfo;
- private String[] dim;
- private int dims;
- private DimensionIntervalElement elem;
-
- public TrimCoverageExpr(Node node, XmlQuery xq) throws WCPSException, InvalidCrsException {
- Node child, axisNode;
- String nodeName;
-
- axisList = new ArrayList<DimensionIntervalElement>();
-
- child = node.getFirstChild();
- 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 DimensionIntervalElement(child, xq, coverageInfo);
- axisList.add(elem);
- child = elem.getNextNode();
- continue;
- } catch (WCPSException e) {
- System.err.println("This was no Dimension Interval 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<DimensionIntervalElement> i = axisList.iterator();
-
- System.out.println("Axis List count:" + axisList.size());
- DimensionIntervalElement axis;
- int axisId;
- int axisLo, axisHi;
-
- while (i.hasNext()) {
- axis = i.next();
- axisId = coverageInfo.getDomainIndexByName(axis.getAxisName());
- System.out.println("Axis ID: " + axisId);
- System.out.println("Axis name: " + axis.getAxisName());
- System.out.print("Axis coords: ");
-
- axisLo = Integer.parseInt(axis.getLowCoord());
- axisHi = Integer.parseInt(axis.getHighCoord());
- dim[axisId] = axisLo + ":" + axisHi;
- coverageInfo.setCellDimension(
- axisId,
- new CellDomainElement(
- BigInteger.valueOf(axisLo), BigInteger.valueOf(axisHi)));
- }
-
- }
-
- 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 org.w3c.dom.*;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class TrimCoverageExpr implements IRasNode, ICoverageInfo {
+
+ private List<DimensionIntervalElement> axisList;
+ private CoverageExpr coverageExprType;
+ private CoverageInfo coverageInfo;
+ private String[] dim;
+ private int dims;
+ private DimensionIntervalElement elem;
+
+ public TrimCoverageExpr(Node node, XmlQuery xq) throws WCPSException {
+ Node child, axisNode;
+ String nodeName;
+
+ axisList = new ArrayList<DimensionIntervalElement>();
+
+ child = node.getFirstChild();
+ 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 DimensionIntervalElement(child, xq, coverageInfo);
+ axisList.add(elem);
+ child = elem.getNextNode();
+ continue;
+ } catch (WCPSException e) {
+ System.err.println("This was no Dimension Interval 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<DimensionIntervalElement> i = axisList.iterator();
+
+ System.out.println("Axis List count:" + axisList.size());
+ DimensionIntervalElement axis;
+ int axisId;
+ int axisLo, axisHi;
+
+ while (i.hasNext()) {
+ axis = i.next();
+ axisId = coverageInfo.getDomainIndexByName(axis.getAxisName());
+ System.out.println("Axis ID: " + axisId);
+ System.out.println("Axis name: " + axis.getAxisName());
+ System.out.print("Axis coords: ");
+
+ axisLo = Integer.parseInt(axis.getLowCoord());
+ axisHi = Integer.parseInt(axis.getHighCoord());
+ dim[axisId] = axisLo + ":" + axisHi;
+ coverageInfo.setCellDimension(
+ axisId,
+ new CellDomainElement(
+ BigInteger.valueOf(axisLo), BigInteger.valueOf(axisHi)));
+ }
+
+ }
+
+ 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;
+ }
+}