summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Aiordachioaie <a.aiordachioaie@jacobs-university.de>2009-07-07 11:13:40 +0200
committerAndrei Aiordachioaie <a.aiordachioaie@jacobs-university.de>2009-07-07 11:13:40 +0200
commit6ed94292898ce9efe4d1547329250f829d4e5c2d (patch)
tree63b7103acb7bed37c5a3c4330ae7ef08482305a6
parent27c4db2703ae90dfeaaa82d058c49f403607c05c (diff)
downloadrasdaman-upstream-6ed94292898ce9efe4d1547329250f829d4e5c2d.tar.gz
rasdaman-upstream-6ed94292898ce9efe4d1547329250f829d4e5c2d.tar.xz
rasdaman-upstream-6ed94292898ce9efe4d1547329250f829d4e5c2d.zip
Fixed annoyance about time axis domain
-rw-r--r--src/grammar/CoverageExpr.java4
-rw-r--r--src/wcps/server/core/AxisName.java6
-rw-r--r--src/wcps/server/core/CachedMetadataSource.java6
-rw-r--r--src/wcps/server/core/ConstantCoverageExpr.java2
-rw-r--r--src/wcps/server/core/ConstructCoverageExpr.java2
-rw-r--r--src/wcps/server/core/CoverageExprPairType.java2
-rw-r--r--src/wcps/server/core/DbMetadataSource.java17
-rw-r--r--src/wcps/server/core/DomainElement.java18
-rw-r--r--src/wcps/server/core/DynamicMetadataSource.java6
-rw-r--r--src/wcps/server/core/IDynamicMetadataSource.java10
-rw-r--r--src/wcps/server/core/IMetadataSource.java3
-rw-r--r--src/wcps/server/core/Metadata.java632
-rw-r--r--src/wcps/server/core/ScalarExpr.java8
13 files changed, 369 insertions, 347 deletions
diff --git a/src/grammar/CoverageExpr.java b/src/grammar/CoverageExpr.java
index 695411c..ed8f96d 100644
--- a/src/grammar/CoverageExpr.java
+++ b/src/grammar/CoverageExpr.java
@@ -81,6 +81,10 @@ public class CoverageExpr implements IParseTreeNode
else if (function.equals("unaryOp"))
{
formatOperation();
+ if (op.equals("plus"))
+ op = "unaryPlus";
+ if (op.equals("minus"))
+ op = "unaryMinus";
result = "<" + op + ">" + expr.toXML() + "</" + op + ">";
}
else if (function.equals("child"))
diff --git a/src/wcps/server/core/AxisName.java b/src/wcps/server/core/AxisName.java
index 90d9524..a317358 100644
--- a/src/wcps/server/core/AxisName.java
+++ b/src/wcps/server/core/AxisName.java
@@ -23,6 +23,7 @@
package wcps.server.core;
+import java.util.Collection;
import org.w3c.dom.*;
public class AxisName implements IRasNode
@@ -41,7 +42,10 @@ public class AxisName implements IRasNode
if (node != null && node.getNodeName().equals("axis"))
{
String axis = node.getTextContent();
- if (axis.length() == 1 && "xyzt".contains(axis))
+ // validate axis name
+ IDynamicMetadataSource meta = xq.getMetadataSource();
+ Collection<String> axisNames = meta.getAxisNames();
+ if (axisNames.contains(axis))
this.name = axis;
else
throw new WCPSException("Unknown axis name " + axis);
diff --git a/src/wcps/server/core/CachedMetadataSource.java b/src/wcps/server/core/CachedMetadataSource.java
index 6f41551..b09f1a7 100644
--- a/src/wcps/server/core/CachedMetadataSource.java
+++ b/src/wcps/server/core/CachedMetadataSource.java
@@ -23,6 +23,7 @@
package wcps.server.core;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -110,4 +111,9 @@ public class CachedMetadataSource implements IMetadataSource
return metadata.get(coverageName).clone();
}
+
+ public Collection<String> getAxisNames()
+ {
+ return metadataSource.getAxisNames();
+ }
}
diff --git a/src/wcps/server/core/ConstantCoverageExpr.java b/src/wcps/server/core/ConstantCoverageExpr.java
index fca04c2..0033e9f 100644
--- a/src/wcps/server/core/ConstantCoverageExpr.java
+++ b/src/wcps/server/core/ConstantCoverageExpr.java
@@ -153,7 +153,7 @@ public class ConstantCoverageExpr implements IRasNode, ICoverageInfo
crsset.add(crs);
DomainElement domain = new DomainElement(axisName, axisType,
ai.getLow().doubleValue(), ai.getHigh().doubleValue(),
- null, null, crsset);
+ null, null, crsset, xq.getMetadataSource().getAxisNames());
domainList.add(domain);
}
// TODO: check element datatypes and their consistency
diff --git a/src/wcps/server/core/ConstructCoverageExpr.java b/src/wcps/server/core/ConstructCoverageExpr.java
index b93b5de..64a129f 100644
--- a/src/wcps/server/core/ConstructCoverageExpr.java
+++ b/src/wcps/server/core/ConstructCoverageExpr.java
@@ -152,7 +152,7 @@ public class ConstructCoverageExpr implements IRasNode, ICoverageInfo
crsset.add(crs);
DomainElement domain = new DomainElement(axisName, axisType,
ai.getLow().doubleValue(), ai.getHigh().doubleValue(),
- null, null, crsset);
+ null, null, crsset, xq.getMetadataSource().getAxisNames());
domainList.add(domain);
}
// "unsigned int" is default datatype
diff --git a/src/wcps/server/core/CoverageExprPairType.java b/src/wcps/server/core/CoverageExprPairType.java
index f11e2f1..2f36593 100644
--- a/src/wcps/server/core/CoverageExprPairType.java
+++ b/src/wcps/server/core/CoverageExprPairType.java
@@ -44,7 +44,7 @@ public class CoverageExprPairType implements IRasNode, ICoverageInfo
{
first = new CoverageExpr(node, xq);
second = new CoverageExpr(node.getNextSibling(), xq);
- info = new CoverageInfo(((ICoverageInfo) second).getCoverageInfo());
+ info = new CoverageInfo(((ICoverageInfo) first).getCoverageInfo());
ok = true;
}
catch (WCPSException e)
diff --git a/src/wcps/server/core/DbMetadataSource.java b/src/wcps/server/core/DbMetadataSource.java
index 2b5f52e..fad4f9d 100644
--- a/src/wcps/server/core/DbMetadataSource.java
+++ b/src/wcps/server/core/DbMetadataSource.java
@@ -32,6 +32,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -39,7 +40,14 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-//The DbMetadataSource is a IMetadataSource that uses a relational database. It keeps a global connection which is reused on future requests, as well as between threads. Before each read, the connection is verified to be valid, and recreated if necessary. This IMetadataSource is not particularly efficient, because it accesses the database at least once for every read. To increase efficiency, wrap a CachedMetadataSource around this one.
+/**The DbMetadataSource is a IMetadataSource that uses a relational database. It
+ * keeps a global connection which is reused on future requests, as well as between
+ * threads. Before each read, the connection is verified to be valid, and
+ * recreated if necessary. This IMetadataSource is not particularly efficient,
+ * because it accesses the database at least once for every read. To increase
+ * efficiency, wrap a CachedMetadataSource around this one.
+ *
+ */
public class DbMetadataSource implements IMetadataSource
{
@@ -377,7 +385,7 @@ public class DbMetadataSource implements IMetadataSource
domain.add(new DomainElement(r.getString("name"),
axisTypes.get(r.getInt("type")),
numLo, numHi, r.getString("strLo"),
- r.getString("strHi"), crsSet));
+ r.getString("strHi"), crsSet, axisTypes.values()));
}
s.close();
@@ -431,4 +439,9 @@ public class DbMetadataSource implements IMetadataSource
}
}
+
+ public Collection<String> getAxisNames()
+ {
+ return axisTypes.values();
+ }
}
diff --git a/src/wcps/server/core/DomainElement.java b/src/wcps/server/core/DomainElement.java
index 1c71687..56d79a8 100644
--- a/src/wcps/server/core/DomainElement.java
+++ b/src/wcps/server/core/DomainElement.java
@@ -23,11 +23,12 @@
package wcps.server.core;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-//This is an axis i geographic coordinates. See the WCPS standard.
+//This is an axis in geographic coordinates. See the WCPS standard.
class DomainElement implements Cloneable
{
@@ -39,11 +40,14 @@ class DomainElement implements Cloneable
private String strHi;
private String strLo;
private String type;
+ private Collection<String> allowedAxes;
public DomainElement(String name, String type, Double numLo, Double numHi, String strLo,
- String strHi, Set<String> crss)
+ String strHi, Set<String> crss, Collection<String> axes)
throws InvalidMetadataException
{
+ this.allowedAxes = axes;
+
if ((name == null) || (type == null))
{
throw new InvalidMetadataException(
@@ -56,11 +60,11 @@ class DomainElement implements Cloneable
"Invalid domain element: Element name cannot be empty");
}
- if (!(type.equals("x") || type.equals("y") || type.equals("temporal")
- || type.equals("elevation") || type.equals("other")))
+ if (allowedAxes.contains(type) == false)
{
throw new InvalidMetadataException(
- "Invalid domain element: Invlaid element type: " + type);
+ "Invalid domain element: Invalid element type: " + type +
+ ". Allowed element types are: " + allowedAxes.toString());
}
if ((numLo != null) && (numHi != null) && (strLo == null) && (strHi == null))
@@ -133,13 +137,13 @@ class DomainElement implements Cloneable
{
return new DomainElement(new String(name), new String(type),
new Double(numLo), new Double(numHi),
- null, null, c);
+ null, null, c, allowedAxes);
}
else
{
return new DomainElement(new String(name), new String(type), null,
null, new String(strLo),
- new String(strHi), c);
+ new String(strHi), c, allowedAxes);
}
}
catch (InvalidMetadataException ime)
diff --git a/src/wcps/server/core/DynamicMetadataSource.java b/src/wcps/server/core/DynamicMetadataSource.java
index fcb403f..84a2159 100644
--- a/src/wcps/server/core/DynamicMetadataSource.java
+++ b/src/wcps/server/core/DynamicMetadataSource.java
@@ -23,6 +23,7 @@
package wcps.server.core;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -108,4 +109,9 @@ public class DynamicMetadataSource implements IDynamicMetadataSource
allCoverageNames = staticCoverageNames;
allCoverageNames.addAll(dynamicCoverageNames);
}
+
+ public Collection<String> getAxisNames()
+ {
+ return metadataSource.getAxisNames();
+ }
}
diff --git a/src/wcps/server/core/IDynamicMetadataSource.java b/src/wcps/server/core/IDynamicMetadataSource.java
index 8a0f4a9..a281fc9 100644
--- a/src/wcps/server/core/IDynamicMetadataSource.java
+++ b/src/wcps/server/core/IDynamicMetadataSource.java
@@ -23,8 +23,6 @@
package wcps.server.core;
-import java.util.Set;
-
/**
* A IDynamicMetadataSource is an IMetadataSource that can also add information
* about new coverages on-the-fly. This is useful for queries that construct
@@ -32,13 +30,7 @@ import java.util.Set;
* database.
*/
-public interface IDynamicMetadataSource
+public interface IDynamicMetadataSource extends IMetadataSource
{
- public Set<String> coverages() throws ResourceException;
-
- public String mimetype(String format);
-
- public Metadata read(String coverageName) throws InvalidRequestException, ResourceException;
-
public void addDynamicMetadata(String coverageName, Metadata meta);
}
diff --git a/src/wcps/server/core/IMetadataSource.java b/src/wcps/server/core/IMetadataSource.java
index ef7bb63..202c36a 100644
--- a/src/wcps/server/core/IMetadataSource.java
+++ b/src/wcps/server/core/IMetadataSource.java
@@ -23,6 +23,7 @@
package wcps.server.core;
+import java.util.Collection;
import java.util.Set;
/**
@@ -39,4 +40,6 @@ public interface IMetadataSource
public String mimetype(String format);
public Metadata read(String coverageName) throws InvalidRequestException, ResourceException;
+
+ public Collection<String> getAxisNames();
}
diff --git a/src/wcps/server/core/Metadata.java b/src/wcps/server/core/Metadata.java
index 71d3a4b..891c402 100644
--- a/src/wcps/server/core/Metadata.java
+++ b/src/wcps/server/core/Metadata.java
@@ -23,6 +23,8 @@
package wcps.server.core;
+//~--- JDK imports ------------------------------------------------------------
+
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -50,32 +52,26 @@ public class Metadata implements Cloneable
private Set<String> nullSet;
private List<RangeElement> range;
- public Metadata(List<CellDomainElement> cellDomain, List<RangeElement> range,
- Set<String> nullSet, String nullDefault,
- Set<InterpolationMethod> interpolationSet,
- InterpolationMethod interpolationDefault, String coverageName,
- List<DomainElement> domain)
- throws InvalidMetadataException
+ public Metadata(List<CellDomainElement> cellDomain, List<RangeElement> range, Set<String> nullSet, String nullDefault, Set<InterpolationMethod> interpolationSet, InterpolationMethod interpolationDefault, String coverageName, List<DomainElement> domain) throws InvalidMetadataException
{
- if ((cellDomain == null) || (range == null) || (coverageName == null)
- || (nullSet == null) || (interpolationSet == null))
+ if ( (cellDomain == null) || (range == null) || (coverageName == null) || (nullSet == null) || (interpolationSet == null) )
{
- throw new InvalidMetadataException(
- "Cell domain, range list, coverage name, null set, and interpolation set cannot be null");
+ throw new InvalidMetadataException("Cell domain, range list, " +
+ "coverage name, null set, and interpolation set cannot be null for coverage " + coverageName);
}
- if (cellDomain.size() == 0)
+ if ( cellDomain.size() == 0 )
{
- throw new InvalidMetadataException(
- "Invalid cell domain: At least one element is required");
+ throw new InvalidMetadataException("Invalid cell domain: At least " +
+ "one element is required for coverage " + coverageName);
}
this.cellDomain = cellDomain;
- if (range.size() == 0)
+ if ( range.size() == 0 )
{
- throw new InvalidMetadataException(
- "At least one range element is required");
+ throw new InvalidMetadataException("At least one range element is " +
+ "required for coverage " + coverageName);
}
this.range = new ArrayList<RangeElement>(range.size());
@@ -83,126 +79,126 @@ public class Metadata implements Cloneable
while (ir.hasNext())
{
- RangeElement next = ir.next();
+ RangeElement next = ir.next();
Iterator<RangeElement> j = this.range.iterator();
while (j.hasNext())
{
- if (j.next().getName().equals(next.getName()))
+ if ( j.next().getName().equals(next.getName()) )
{
- throw new InvalidMetadataException(
- "Duplicate range element name encountered");
+ throw new InvalidMetadataException("Duplicate range element" +
+ " name encountered for coverage " + coverageName);
}
}
this.range.add(next);
}
- if (nullSet.size() == 0)
- { // TODO: check with Peter
- throw new InvalidMetadataException(
- "Invalid null set: At least one null value is required");
+ if ( nullSet.size() == 0 )
+ {
+ throw new InvalidMetadataException("Invalid null set: At least one " +
+ "null value is required for coverage " + coverageName);
}
- if (nullDefault == null)
+ if ( nullDefault == null )
{
- throw new InvalidMetadataException(
- "Invalid null default: Null default cannot be null");
+ throw new InvalidMetadataException("Invalid null default: Null " +
+ "default cannot be null for coverage " + coverageName);
}
- if (!nullSet.contains(nullDefault))
+ if ( ! nullSet.contains(nullDefault) )
{
- throw new InvalidMetadataException(
- "Invalid null default: Default null value " + nullDefault
- + " is not part of the null set");
+ throw new InvalidMetadataException("Invalid null default: Default " +
+ "null value " + nullDefault + " is not part of the null set" +
+ " for coverage " + coverageName);
}
Iterator<String> ns = nullSet.iterator();
while (ns.hasNext())
{
- String nullVal = ns.next();
+ String nullVal = ns.next();
List<String> nulls = SDU.str2string(nullVal);
- if (nulls.size() != range.size())
+ if ( nulls.size() != range.size() )
{
- throw new InvalidMetadataException(
- "Invalid null value: " + nullVal + " must have " + range.size()
- + " axes according to the range specified for coverage "
- + coverageName);
+ throw new InvalidMetadataException("Invalid null value: " +
+ nullVal + " must have " + range.size() + " axes " +
+ "according to the range specified for coverage " + coverageName);
}
- Iterator<String> i = nulls.iterator();
+ Iterator<String> i = nulls.iterator();
Iterator<RangeElement> j = range.iterator();
while (j.hasNext())
{
RangeElement re = j.next();
- if (re.isBoolean())
+ if ( re.isBoolean() )
{
SDU.str2boolean(i.next());
}
- else if (re.isIntegral())
+ else if ( re.isIntegral() )
{
SDU.str2integer(i.next());
}
- else if (re.isFloating())
+ else if ( re.isFloating() )
{
SDU.str2double(i.next());
}
- else if (re.isComplex())
+ else if ( re.isComplex() )
{
SDU.str2complex(i.next());
}
}
}
- this.nullSet = nullSet;
+ this.nullSet = nullSet;
this.nullDefault = nullDefault;
- if (interpolationSet.size() == 0)
- { // TODO: check with Peter
- throw new InvalidMetadataException(
- "Invalid interpolation set: At least one interpolation method is required");
+ if ( interpolationSet.size() == 0 )
+ {
+ throw new InvalidMetadataException("Invalid interpolation set: " +
+ "At least one interpolation method is required for " +
+ "coverage " + coverageName);
}
- if (interpolationDefault == null)
+ if ( interpolationDefault == null )
{
interpolationDefault = new InterpolationMethod("none", "none");
}
- boolean defaultContainedInSet = false;
+ boolean defaultContainedInSet = false;
Iterator<InterpolationMethod> is = interpolationSet.iterator();
while (is.hasNext())
{
- if (interpolationDefault.equals(is.next()))
+ if ( interpolationDefault.equals(is.next()) )
{
defaultContainedInSet = true;
}
}
- if (!defaultContainedInSet)
+ if ( ! defaultContainedInSet )
{
- throw new InvalidMetadataException(
- "Ivanlid interpolation default: Default interpolation method ("
- + interpolationDefault.getInterpolationType() + ","
- + interpolationDefault.getNullResistance()
- + ") is not part of the interpolation set");
+ throw new InvalidMetadataException("Ivanlid interpolation default:" +
+ " Default interpolation method (" +
+ interpolationDefault.getInterpolationType() + "," +
+ interpolationDefault.getNullResistance() + ") is not part " +
+ "of the interpolation set for coverage " + coverageName);
}
- this.interpolationSet = interpolationSet;
+ this.interpolationSet = interpolationSet;
this.interpolationDefault = interpolationDefault;
- this.coverageName = coverageName;
+ this.coverageName = coverageName;
- if (domain != null)
+ if ( domain != null )
{
- if (domain.size() != cellDomain.size())
+ if ( domain.size() != cellDomain.size() )
{
- throw new InvalidMetadataException(
- "Domain and cell domain must have equal number of elements");
+ throw new InvalidMetadataException("Domain and cell domain " +
+ "must have equal number of elements for coverage " + coverageName);
}
this.domain = new ArrayList<DomainElement>(domain.size());
@@ -210,83 +206,85 @@ public class Metadata implements Cloneable
while (i.hasNext())
{
- DomainElement next = i.next();
+ DomainElement next = i.next();
Iterator<DomainElement> j = this.domain.iterator();
while (j.hasNext())
{
DomainElement previous = j.next();
- if (previous.getName().equals(next.getName()))
+ // don't compare same objects
+ if (next == previous)
+ continue;
+
+ if ( previous.getName().equals(next.getName()) )
{
- throw new InvalidMetadataException(
- "Duplicate domain element name encountered");
+ throw new InvalidMetadataException("Duplicate domain " +
+ "element name encountered for coverage " + coverageName);
}
- if (previous.getType().equals("temporal")
- && next.getType().equals("temporal"))
+ if ( previous.getType().equals("temporal") && next.getType().equals("temporal") )
{
- throw new InvalidMetadataException(
- "Domain can contain at most one temporal axis");
+ throw new InvalidMetadataException("Domain can contain" +
+ " at most one temporal axis for coverage " + coverageName);
}
- if (previous.getType().equals("elevation")
- && next.getType().equals("elevation"))
+ if ( previous.getType().equals("elevation") && next.getType().equals("elevation") )
{
- throw new InvalidMetadataException(
- "Domain can contain at most one elevation axis");
+ throw new InvalidMetadataException("Domain can contain" +
+ " at most one elevation axis for coverage " + coverageName);
}
- if (previous.getType().equals("x")
- && next.getType().equals("x"))
+ if ( previous.getType().equals("x") && next.getType().equals("x") )
{
- throw new InvalidMetadataException(
- "Domain can contain at most one x axis");
+ throw new InvalidMetadataException("Domain can contain" +
+ " at most one x axis for coverage " + coverageName);
}
- if (previous.getType().equals("y")
- && next.getType().equals("y"))
+ if ( previous.getType().equals("y") && next.getType().equals("y") )
{
- throw new InvalidMetadataException(
- "Domain can contain at most one y axis");
+ throw new InvalidMetadataException("Domain can contain" +
+ " at most one y axis for coverage " + coverageName);
}
- if (next.getType().equals("x"))
+ if ( next.getType().equals("x") )
{
- boolean l = false;
+ boolean l = false;
Iterator<DomainElement> k = domain.iterator();
while (k.hasNext())
{
- if (k.next().getType().equals("y"))
+ if ( k.next().getType().equals("y") )
{
l = true;
}
}
- if (l == false)
+ if ( l == false )
{
- throw new InvalidMetadataException(
- "If domain contains a x axis, it must contain a y axis as well");
+ throw new InvalidMetadataException("If domain " +
+ "contains a x axis, it must contain a y " +
+ "axis as well for coverage " + coverageName);
}
}
- else if (next.getType().equals("y"))
+ else if ( next.getType().equals("y") )
{
- boolean l = false;
+ boolean l = false;
Iterator<DomainElement> k = domain.iterator();
while (k.hasNext())
{
- if (k.next().getType().equals("x"))
+ if ( k.next().getType().equals("x") )
{
l = true;
}
}
- if (l == false)
+ if ( l == false )
{
- throw new InvalidMetadataException(
- "If domain contains a y axis, it must contain a x axis as well");
+ throw new InvalidMetadataException("If domain " +
+ "contains a y axis, it must contain a x " +
+ "axis as well for coverage " + coverageName);
}
}
}
@@ -301,8 +299,7 @@ public class Metadata implements Cloneable
{
try
{
- List<CellDomainElement> cd =
- new ArrayList<CellDomainElement>(cellDomain.size());
+ List<CellDomainElement> cd = new ArrayList<CellDomainElement>(cellDomain.size());
Iterator<CellDomainElement> i = cellDomain.iterator();
while (i.hasNext())
@@ -310,7 +307,7 @@ public class Metadata implements Cloneable
cd.add(i.next().clone());
}
- List<RangeElement> r = new ArrayList<RangeElement>(range.size());
+ List<RangeElement> r = new ArrayList<RangeElement>(range.size());
Iterator<RangeElement> j = range.iterator();
while (j.hasNext())
@@ -318,7 +315,7 @@ public class Metadata implements Cloneable
r.add(j.next().clone());
}
- List<DomainElement> d = new ArrayList<DomainElement>(domain.size());
+ List<DomainElement> d = new ArrayList<DomainElement>(domain.size());
Iterator<DomainElement> k = domain.iterator();
while (k.hasNext())
@@ -326,7 +323,7 @@ public class Metadata implements Cloneable
d.add(k.next().clone());
}
- Set<String> ns = new HashSet<String>(nullSet.size());
+ Set<String> ns = new HashSet<String>(nullSet.size());
Iterator<String> l = nullSet.iterator();
while (l.hasNext())
@@ -334,8 +331,7 @@ public class Metadata implements Cloneable
ns.add(new String(l.next()));
}
- Set<InterpolationMethod> is =
- new HashSet<InterpolationMethod>(interpolationSet.size());
+ Set<InterpolationMethod> is = new HashSet<InterpolationMethod>(interpolationSet.size());
Iterator<InterpolationMethod> m = interpolationSet.iterator();
while (m.hasNext())
@@ -343,24 +339,21 @@ public class Metadata implements Cloneable
is.add(m.next().clone());
}
- return new Metadata(cd, r, ns, new String(nullDefault), is,
- interpolationDefault.clone(), new String(coverageName),
- d);
+ return new Metadata(cd, r, ns, new String(nullDefault), is, interpolationDefault.clone(), new String(coverageName), d);
}
catch (InvalidMetadataException ime)
{
- throw new RuntimeException(
- "Invalid metadata while cloning Metadata. This is a software bug in WCPS.",
- ime);
+ throw new RuntimeException("Invalid metadata while cloning " +
+ "Metadata. This is a software bug in WCPS.", ime);
}
}
-// public CellDomainElement getCellDomain( int index ) {
+// public CellDomainElement getCellDomain( int index ) {
//
-// return cellDomain.get( index );
+// return cellDomain.get( index );
//
-// }
+// }
public Iterator<CellDomainElement> getCellDomainIterator()
{
@@ -379,19 +372,19 @@ public class Metadata implements Cloneable
}
-// public DomainElement getDomainByType( String type ) {
+// public DomainElement getDomainByType( String type ) {
//
-// Iterator<DomainElement> i = domain.iterator();
-// DomainElement de;
-// while( i.hasNext() ) {
-// de = i.next();
-// if( de.getType().equals( type ) ) {
-// return de;
-// }
+// Iterator<DomainElement> i = domain.iterator();
+// DomainElement de;
+// while( i.hasNext() ) {
+// de = i.next();
+// if( de.getType().equals( type ) ) {
+// return de;
// }
-// return null;
-//
// }
+// return null;
+//
+// }
public int getDomainIndexByName(String name)
{
@@ -399,7 +392,7 @@ public class Metadata implements Cloneable
for (int index = 0; i.hasNext(); index++)
{
- if (i.next().getName().equals(name))
+ if ( i.next().getName().equals(name) )
{
return index;
}
@@ -408,23 +401,23 @@ public class Metadata implements Cloneable
return -1;
}
-// public int getDomainIndexByType( String type ) {
+// public int getDomainIndexByType( String type ) {
//
-// Iterator<DomainElement> i = domain.iterator();
-// for( int index = 0; i.hasNext(); index++ ) {
-// if( i.next().getName().equals( type ) ) {
-// return index;
-// }
+// Iterator<DomainElement> i = domain.iterator();
+// for( int index = 0; i.hasNext(); index++ ) {
+// if( i.next().getName().equals( type ) ) {
+// return index;
// }
-// return -1;
-//
// }
+// return -1;
+//
+// }
-// public String getDomainType( int index ) {
+// public String getDomainType( int index ) {
//
-// return domain.get( index ).getType();
+// return domain.get( index ).getType();
//
-// }
+// }
public String getNullDefault()
{
@@ -438,93 +431,93 @@ public class Metadata implements Cloneable
}
-// public String getRangeType( int index ) {
+// public String getRangeType( int index ) {
//
-// return range.get( index ).getType();
+// return range.get( index ).getType();
//
-// }
+// }
-// public String getRangeType( String name ) {
+// public String getRangeType( String name ) {
//
-// String type = null;
-// Iterator<RangeElement> i = range.iterator();
-// RangeElement re;
-// while( i.hasNext() ) {
-// re = i.next();
-// if( re.getName().equals( name ) ) {
-// type = re.getType();
-// }
+// String type = null;
+// Iterator<RangeElement> i = range.iterator();
+// RangeElement re;
+// while( i.hasNext() ) {
+// re = i.next();
+// if( re.getName().equals( name ) ) {
+// type = re.getType();
// }
-// return type;
-//
// }
+// return type;
+//
+// }
-// public double getResolution( int i ) {
+// public double getResolution( int i ) {
//
-// DomainElement de = domain.get( i );
-// Double deLo = de.getNumLo();
-// Double deHi = de.getNumHi();
-// if( deLo == null ) {
-// return -1;
-// }
+// DomainElement de = domain.get( i );
+// Double deLo = de.getNumLo();
+// Double deHi = de.getNumHi();
+// if( deLo == null ) {
+// return -1;
+// }
//
-// CellDomainElement cde = cellDomain.get( i );
-// BigInteger cdeLo = cde.getLo();
-// BigInteger cdeHi = cde.getHi();
+// CellDomainElement cde = cellDomain.get( i );
+// BigInteger cdeLo = cde.getLo();
+// BigInteger cdeHi = cde.getHi();
//
-// return (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
+// return (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
//
-// }
+// }
-// public boolean isCellDomainEqualTo( Metadata m ) {
+// public boolean isCellDomainEqualTo( Metadata m ) {
//
-// if( m == null ) {
-// return false;
-// }
+// if( m == null ) {
+// return false;
+// }
//
-// Iterator<CellDomainElement> i = cellDomain.iterator();
-// Iterator<CellDomainElement> j = m.cellDomain.iterator();
-// while( i.hasNext() && j.hasNext() ) {
-// if( !i.next().equals( j.next() ) ) {
-// return false;
-// }
-// }
-// if( i.hasNext() || j.hasNext() ) {
+// Iterator<CellDomainElement> i = cellDomain.iterator();
+// Iterator<CellDomainElement> j = m.cellDomain.iterator();
+// while( i.hasNext() && j.hasNext() ) {
+// if( !i.next().equals( j.next() ) ) {
// return false;
// }
-// return true;
-//
// }
-
-// public boolean isCrsValid( String crs ) {
-// return crs != null && (crs.equals( "" ) || crs.startsWith( "urn:ogc:def:crs:EPSG::" ));
+// if( i.hasNext() || j.hasNext() ) {
+// return false;
// }
+// return true;
+//
+// }
-// public boolean isDomainEqualTo (Metadata m) {
+// public boolean isCrsValid( String crs ) {
+// return crs != null && (crs.equals( "" ) || crs.startsWith( "urn:ogc:def:crs:EPSG::" ));
+// }
+
+// public boolean isDomainEqualTo (Metadata m) {
//
-// if( m == null ) {
-// return false;
-// }
+// if( m == null ) {
+// return false;
+// }
//
-// Iterator<DomainElement> i = domain.iterator();
-// Iterator<DomainElement> j = m.domain.iterator();
-// while( i.hasNext() && j.hasNext() ) {
-// if( !i.next().equals( j.next() ) ) {
-// return false;
-// }
-// }
-// if( i.hasNext() || j.hasNext() ) {
+// Iterator<DomainElement> i = domain.iterator();
+// Iterator<DomainElement> j = m.domain.iterator();
+// while( i.hasNext() && j.hasNext() ) {
+// if( !i.next().equals( j.next() ) ) {
// return false;
// }
-// return true;
-//
// }
+// if( i.hasNext() || j.hasNext() ) {
+// return false;
+// }
+// return true;
+//
+// }
-// public boolean isInterpolationMethodValid( String im ) {
+// public boolean isInterpolationMethodValid( String im ) {
//
-// return im != null && im.equals( "nearest neighbor" );
+// return im != null && im.equals( "nearest neighbor" );
//
-// }
+// }
public boolean isRangeBoolean()
{
@@ -532,7 +525,7 @@ public class Metadata implements Cloneable
while (i.hasNext())
{
- if (!i.next().isBoolean())
+ if ( ! i.next().isBoolean() )
{
return false;
}
@@ -548,7 +541,7 @@ public class Metadata implements Cloneable
while (i.hasNext())
{
- if (!i.next().isComplex())
+ if ( ! i.next().isComplex() )
{
return false;
}
@@ -564,7 +557,7 @@ public class Metadata implements Cloneable
while (i.hasNext())
{
- if (!i.next().isIntegral())
+ if ( ! i.next().isIntegral() )
{
return false;
}
@@ -574,25 +567,25 @@ public class Metadata implements Cloneable
}
-// public boolean isRangeEqualTo (Metadata m) {
+// public boolean isRangeEqualTo (Metadata m) {
//
-// if( m == null ) {
-// return false;
-// }
+// if( m == null ) {
+// return false;
+// }
//
-// Iterator<RangeElement> i = range.iterator();
-// Iterator<RangeElement> j = m.range.iterator();
-// while( i.hasNext() && j.hasNext() ) {
-// if( !i.next().equals( j.next() ) ) {
-// return false;
-// }
-// }
-// if( i.hasNext() || j.hasNext() ) {
+// Iterator<RangeElement> i = range.iterator();
+// Iterator<RangeElement> j = m.range.iterator();
+// while( i.hasNext() && j.hasNext() ) {
+// if( !i.next().equals( j.next() ) ) {
// return false;
// }
-// return true;
-//
// }
+// if( i.hasNext() || j.hasNext() ) {
+// return false;
+// }
+// return true;
+//
+// }
public boolean isRangeFloating()
{
@@ -600,7 +593,7 @@ public class Metadata implements Cloneable
while (i.hasNext())
{
- if (!i.next().isFloating())
+ if ( ! i.next().isFloating() )
{
return false;
}
@@ -616,7 +609,7 @@ public class Metadata implements Cloneable
while (i.hasNext())
{
- if (!i.next().isNumeric())
+ if ( ! i.next().isNumeric() )
{
return false;
}
@@ -626,117 +619,116 @@ public class Metadata implements Cloneable
}
-// public boolean isResolutionEqualTo( Metadata m ) {
+// public boolean isResolutionEqualTo( Metadata m ) {
//
-// if( m == null || getDimension() != m.getDimension() ) {
-// return false;
-// }
+// if( m == null || getDimension() != m.getDimension() ) {
+// return false;
+// }
//
-// Iterator<CellDomainElement> cdIterator1 = cellDomain.iterator();
-// Iterator<CellDomainElement> cdIterator2 = m.cellDomain.iterator();
-// Iterator<DomainElement> dIterator1 = domain.iterator();
-// Iterator<DomainElement> dIterator2 = m.domain.iterator();
-// double resolution1;
-// double resolution2;
-// CellDomainElement cde;
-// DomainElement de;
-// Double deLo;
-// Double deHi;
-// BigInteger cdeLo;
-// BigInteger cdeHi;
-// while( cdIterator1.hasNext() ) {
-// cde = cdIterator1.next();
-// de = dIterator1.next();
-// deLo = de.getNumLo();
-// deHi = de.getNumHi();
-// if( deLo == null ) {
-// resolution1 = -1;
-// }
-// cdeLo = cde.getLo();
-// cdeHi = cde.getHi();
-// resolution1 = (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
-// cde = cdIterator1.next();
-// de = dIterator1.next();
-// deLo = de.getNumLo();
-// deHi = de.getNumHi();
-// if( deLo == null ) {
-// resolution2 = -1;
-// }
-// cdeLo = cde.getLo();
-// cdeHi = cde.getHi();
-// resolution2 = (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
-// if( resolution1 != resolution2 ) {
-// return false;
-// }
+// Iterator<CellDomainElement> cdIterator1 = cellDomain.iterator();
+// Iterator<CellDomainElement> cdIterator2 = m.cellDomain.iterator();
+// Iterator<DomainElement> dIterator1 = domain.iterator();
+// Iterator<DomainElement> dIterator2 = m.domain.iterator();
+// double resolution1;
+// double resolution2;
+// CellDomainElement cde;
+// DomainElement de;
+// Double deLo;
+// Double deHi;
+// BigInteger cdeLo;
+// BigInteger cdeHi;
+// while( cdIterator1.hasNext() ) {
+// cde = cdIterator1.next();
+// de = dIterator1.next();
+// deLo = de.getNumLo();
+// deHi = de.getNumHi();
+// if( deLo == null ) {
+// resolution1 = -1;
+// }
+// cdeLo = cde.getLo();
+// cdeHi = cde.getHi();
+// resolution1 = (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
+// cde = cdIterator1.next();
+// de = dIterator1.next();
+// deLo = de.getNumLo();
+// deHi = de.getNumHi();
+// if( deLo == null ) {
+// resolution2 = -1;
+// }
+// cdeLo = cde.getLo();
+// cdeHi = cde.getHi();
+// resolution2 = (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
+// if( resolution1 != resolution2 ) {
+// return false;
// }
-// return true;
-//
// }
+// return true;
+//
+// }
-// public boolean isTypeValid( String type ) {
-// return type != null && (type.equals( "char" ) || type.equals( "unsigned char" ) || type.equals( "short" ) || type.equals( "unsigned short" ) || type.equals( "int" ) || type.equals( "unsigned int" ) || type.equals( "long" ) || type.equals( "unsigned long" ) || type.equals( "float" ) || type.equals( "double" )); // TODO: fix
-// }
+// public boolean isTypeValid( String type ) {
+// return type != null && (type.equals( "char" ) || type.equals( "unsigned char" ) || type.equals( "short" ) || type.equals( "unsigned short" ) || type.equals( "int" ) || type.equals( "unsigned int" ) || type.equals( "long" ) || type.equals( "unsigned long" ) || type.equals( "float" ) || type.equals( "double" )); // TODO: fix
+// }
-// public void removeFromCellDomain( int index ) throws InvalidMetadataException {
-//
-// cellDomain.remove( index );
-// if( cellDomain.size() == 0 ) {
-// throw new InvalidMetadataException( "Metadata transformation: Cell domain cannot be empty" );
-// }
+// public void removeFromCellDomain( int index ) throws InvalidMetadataException {
//
+// cellDomain.remove( index );
+// if( cellDomain.size() == 0 ) {
+// throw new InvalidMetadataException( "Metadata transformation: Cell domain cannot be empty" );
// }
-
-// public void removeFromDomain( int index ) throws InvalidMetadataException {
//
-// domain.remove( index );
-// if( domain.size() == 0 ) {
-// throw new InvalidMetadataException( "Metadata transformation: Domain cannot be empty" );
-// }
+// }
+
+// public void removeFromDomain( int index ) throws InvalidMetadataException {
//
+// domain.remove( index );
+// if( domain.size() == 0 ) {
+// throw new InvalidMetadataException( "Metadata transformation: Domain cannot be empty" );
// }
+//
+// }
public void setCoverageName(String coverageName) throws InvalidMetadataException
{
- if (coverageName == null)
+ if ( coverageName == null )
{
- throw new InvalidMetadataException(
- "Metadata transformation: Coverage name cannot be null");
+ throw new InvalidMetadataException("Metadata transformation: Coverage name cannot be null");
}
this.coverageName = coverageName;
}
-// public void setCrs( String crs ) throws InvalidMetadataException {
-//
-// if( crs == null ) {
-// throw new InvalidMetadataException( "Metadata transformation: CRS cannot be null" );
-// }
-// if( !(crs.equals( "" ) || crs.startsWith( "urn:ogc:def:crs:EPSG::" )) ) {
-// throw new InvalidMetadataException( "Metadata transformation: Invalid CRS" );
-// }
-// this.crs = crs;
+// public void setCrs( String crs ) throws InvalidMetadataException {
//
+// if( crs == null ) {
+// throw new InvalidMetadataException( "Metadata transformation: CRS cannot be null" );
+// }
+// if( !(crs.equals( "" ) || crs.startsWith( "urn:ogc:def:crs:EPSG::" )) ) {
+// throw new InvalidMetadataException( "Metadata transformation: Invalid CRS" );
// }
+// this.crs = crs;
+//
+// }
-// public void setInterpolationMethodList( List<String> interpolationMethodList ) throws InvalidMetadataException {
+// public void setInterpolationMethodList( List<String> interpolationMethodList ) throws InvalidMetadataException {
//
-// this.interpolationMethodList = interpolationMethodList;
-// Iterator<String> is = interpolationMethodList.iterator();
-// while( is.hasNext() ) {
-// String next = is.next();
-// if( !(next.equals( "nearest neighbor" ) || next.equals( "bilinear" ) || next.equals( "bicubic" ) || next.equals( "lost area" ) || next.equals( "barycentric" )) ) {
-// throw new InvalidMetadataException( "Metadata transformation: Invalid interpolation method" );
-// }
+// this.interpolationMethodList = interpolationMethodList;
+// Iterator<String> is = interpolationMethodList.iterator();
+// while( is.hasNext() ) {
+// String next = is.next();
+// if( !(next.equals( "nearest neighbor" ) || next.equals( "bilinear" ) || next.equals( "bicubic" ) || next.equals( "lost area" ) || next.equals( "barycentric" )) ) {
+// throw new InvalidMetadataException( "Metadata transformation: Invalid interpolation method" );
// }
-//
// }
+//
+// }
-// public void setNullValue( String nullValue ) {
+// public void setNullValue( String nullValue ) {
//
-// this.nullValue = nullValue;
+// this.nullValue = nullValue;
//
-// }
+// }
public void setRangeType(String type) throws InvalidMetadataException
{
@@ -749,54 +741,50 @@ public class Metadata implements Cloneable
}
-// public void setRangeType( List<String> types ) throws InvalidMetadataException {
-//
-// if( types.size() != range.size() ) {
-// throw new InvalidMetadataException( "Invalid range type: New type has " + types.size() + " elements, but range has " + range.size() + " elements" );
-// }
-// Iterator<RangeElement> i = range.iterator();
-// Iterator<String> j = types.iterator();
-// while( i.hasNext() ) {
-// i.next().setType( j.next() );
-// }
+// public void setRangeType( List<String> types ) throws InvalidMetadataException {
//
+// if( types.size() != range.size() ) {
+// throw new InvalidMetadataException( "Invalid range type: New type has " + types.size() + " elements, but range has " + range.size() + " elements" );
+// }
+// Iterator<RangeElement> i = range.iterator();
+// Iterator<String> j = types.iterator();
+// while( i.hasNext() ) {
+// i.next().setType( j.next() );
// }
+//
+// }
-// public void updateCellDomain( int index, BigInteger lo, BigInteger hi ) throws InvalidMetadataException {
+// public void updateCellDomain( int index, BigInteger lo, BigInteger hi ) throws InvalidMetadataException {
//
-// cellDomain.set( index, new CellDomainElement( lo, hi ) );
+// cellDomain.set( index, new CellDomainElement( lo, hi ) );
//
-// }
+// }
-// public void updateDomain( int index, Double numLo, Double numHi, String strLo, String strHi ) throws InvalidMetadataException {
+// public void updateDomain( int index, Double numLo, Double numHi, String strLo, String strHi ) throws InvalidMetadataException {
//
-// DomainElement old = domain.get( index );
-// domain.set( index, new DomainElement( old.getName(), old.getType(), numLo, numHi, strLo, strHi ) );
+// DomainElement old = domain.get( index );
+// domain.set( index, new DomainElement( old.getName(), old.getType(), numLo, numHi, strLo, strHi ) );
//
-// }
+// }
- public void updateNulls(Set<String> nullSet, String nullDefault)
- throws InvalidMetadataException
+ public void updateNulls(Set<String> nullSet, String nullDefault) throws InvalidMetadataException
{
- if (nullSet.size() == 0)
- { // TODO: check with Peter
- throw new InvalidMetadataException(
- "Invalid null set: At least one null value is required");
+ if ( nullSet.size() == 0 )
+ {
+ throw new InvalidMetadataException("Invalid null set: At least one null value is required");
}
- if (nullDefault == null)
+ if ( nullDefault == null )
{
- nullDefault = "0"; // TODO: "false" for booleans, but check whether it is supported by rasdaman
+ nullDefault = "0";
}
- if (!nullSet.contains(nullDefault))
+ if ( ! nullSet.contains(nullDefault) )
{
- throw new InvalidMetadataException(
- "Invalid null default: Default null value " + nullDefault
- + " is not part of the null set");
+ throw new InvalidMetadataException("Invalid null default: Default null value " + nullDefault + " is not part of the null set");
}
- this.nullSet = nullSet;
+ this.nullSet = nullSet;
this.nullDefault = nullDefault;
}
diff --git a/src/wcps/server/core/ScalarExpr.java b/src/wcps/server/core/ScalarExpr.java
index f03d4bf..effb8d5 100644
--- a/src/wcps/server/core/ScalarExpr.java
+++ b/src/wcps/server/core/ScalarExpr.java
@@ -24,6 +24,7 @@
package wcps.server.core;
import java.math.BigInteger;
+import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -132,7 +133,7 @@ public class ScalarExpr implements IRasNode, ICoverageInfo
+ node.getNodeName());
}
- Metadata meta = createScalarExprMetadata();
+ Metadata meta = createScalarExprMetadata(xq);
info = new CoverageInfo(meta);
}
@@ -147,7 +148,7 @@ public class ScalarExpr implements IRasNode, ICoverageInfo
}
/** Builds full metadata for the newly constructed coverage **/
- private Metadata createScalarExprMetadata() throws WCPSException
+ private Metadata createScalarExprMetadata(XmlQuery xq) throws WCPSException
{
List<CellDomainElement> cellDomainList = new LinkedList<CellDomainElement>();
List<RangeElement> rangeList = new LinkedList<RangeElement>();
@@ -165,7 +166,8 @@ public class ScalarExpr implements IRasNode, ICoverageInfo
String crs = DomainElement.IMAGE_CRS;
HashSet<String> crsset = new HashSet<String>();
crsset.add(crs);
- DomainElement domain = new DomainElement("x", "x", 1.0, 1.0, null, null, crsset);
+ Collection<String> allowedAxes = xq.getMetadataSource().getAxisNames();
+ DomainElement domain = new DomainElement("x", "x", 1.0, 1.0, null, null, crsset, allowedAxes);
domainList.add(domain);
// "unsigned int" is default datatype
rangeList.add(new RangeElement("dynamic_type", "unsigned int"));