final String fieldId = field.getIdentifier().getValue(); if (!fieldId.equalsIgnoreCase("contents")) throw new WcsException("Unknown field " + fieldId, InvalidParameterValue, "RangeSubset"); String interpolation = field.getInterpolationType(); if (interpolation != null) { boolean interpolationSupported = false; if (field.getAxisSubset().size() > 1) { throw new WcsException("Multi axis coverages are not supported yet", InvalidParameterValue, "RangeSubset"); } else if (field.getAxisSubset().size() == 0) return; AxisSubsetType axisSubset = (AxisSubsetType) field.getAxisSubset().get(0); final String axisId = axisSubset.getIdentifier(); if (!axisId.equalsIgnoreCase("Bands"))
public Object visit(ASTFieldSubset node, Object data) { FieldSubsetType fs = wcsf.createFieldSubsetType(); for (int i = 0; i < node.jjtGetNumChildren(); i++) { Node child = node.jjtGetChild(i); if(child instanceof ASTFieldId) { CodeType id = owsf.createCodeType(); id.setValue((String) child.jjtAccept(this, null)); fs.setIdentifier(id); } else if(child instanceof ASTInterpolation) { fs.setInterpolationType((String) child.jjtAccept(this, null)); } else if(child instanceof ASTAxisSubset) { fs.getAxisSubset().add(child.jjtAccept(this, null)); } } return fs; }
@Test public void testSimpleFields() throws Exception { RangeSubsetType rs = (RangeSubsetType) parser.parse("radiance;temperature"); assertNotNull(rs); assertEquals(2, rs.getFieldSubset().size()); FieldSubsetType field = (FieldSubsetType) rs.getFieldSubset().get(0); assertEquals("radiance", field.getIdentifier().getValue()); assertEquals(null, field.getInterpolationType()); field = (FieldSubsetType) rs.getFieldSubset().get(1); assertEquals("temperature", field.getIdentifier().getValue()); assertEquals(null, field.getInterpolationType()); }
@Test public void testAxisSingleKey() throws Exception { RangeSubsetType rs = (RangeSubsetType) parser.parse("radiance[bands[Red]]"); assertNotNull(rs); assertEquals(1, rs.getFieldSubset().size()); FieldSubsetType field = (FieldSubsetType) rs.getFieldSubset().get(0); assertEquals("radiance", field.getIdentifier().getValue()); assertEquals(1, field.getAxisSubset().size()); AxisSubsetType axis = (AxisSubsetType) field.getAxisSubset().get(0); assertEquals("bands", axis.getIdentifier()); List keys = axis.getKey(); assertEquals(1, keys.size()); assertEquals("Red", keys.get(0)); }
@Override public Object parse(String value) throws Exception { RangeSubsetParser parser = new RangeSubsetParser(new StringReader(value)); SimpleNode root = parser.RangeSubset(); RangeSubsetType result = (RangeSubsetType) root.jjtAccept(new RangeSubsetKvpParserVisitor(), null); for (Iterator it = result.getFieldSubset().iterator(); it.hasNext();) { FieldSubsetType type = (FieldSubsetType) it.next(); String interpolationType = type.getInterpolationType(); if(interpolationType != null) { try { InterpolationMethod method = InterpolationMethod.valueOf(interpolationType); } catch(IllegalArgumentException e) { throw new WcsException("Unknown interpolation method " + interpolationType, InvalidParameterValue, "RangeSubset"); } } } return result; }
@Test public void testInterpolation() throws Exception { RangeSubsetType rs = (RangeSubsetType) parser.parse("radiance:linear;temperature:nearest"); assertNotNull(rs); assertEquals(2, rs.getFieldSubset().size()); FieldSubsetType field = (FieldSubsetType) rs.getFieldSubset().get(0); assertEquals("radiance", field.getIdentifier().getValue()); assertEquals("linear", field.getInterpolationType()); field = (FieldSubsetType) rs.getFieldSubset().get(1); assertEquals("temperature", field.getIdentifier().getValue()); assertEquals("nearest", field.getInterpolationType()); }
public void testAxisKeys() throws Exception { RangeSubsetType rs = (RangeSubsetType) parser.parse("radiance[bands[Red,Green,Blue]]"); assertNotNull(rs); assertEquals(1, rs.getFieldSubset().size()); FieldSubsetType field = (FieldSubsetType) rs.getFieldSubset().get(0); assertEquals("radiance", field.getIdentifier().getValue()); assertEquals(1, field.getAxisSubset().size()); AxisSubsetType axis = (AxisSubsetType) field.getAxisSubset().get(0); assertEquals("bands", axis.getIdentifier()); List keys = axis.getKey(); assertEquals(3, keys.size()); assertEquals("Red", keys.get(0)); assertEquals("Green", keys.get(1)); assertEquals("Blue", keys.get(2)); } }
@Override public Object parse(String value) throws Exception { RangeSubsetParser parser = new RangeSubsetParser(new StringReader(value)); SimpleNode root = parser.RangeSubset(); RangeSubsetType result = (RangeSubsetType) root.jjtAccept(new RangeSubsetKvpParserVisitor(), null); for (Iterator it = result.getFieldSubset().iterator(); it.hasNext(); ) { FieldSubsetType type = (FieldSubsetType) it.next(); String interpolationType = type.getInterpolationType(); if (interpolationType != null) { try { InterpolationMethod method = InterpolationMethod.valueOf(interpolationType); } catch (IllegalArgumentException e) { throw new WcsException( "Unknown interpolation method " + interpolationType, InvalidParameterValue, "RangeSubset"); } } } return result; }
final String fieldId = field.getIdentifier().getValue(); if (!fieldId.equalsIgnoreCase("contents")) throw new WcsException( String interpolation = field.getInterpolationType(); if (interpolation != null) { boolean interpolationSupported = false; if (field.getAxisSubset().size() > 1) { throw new WcsException( "Multi axis coverages are not supported yet", InvalidParameterValue, "RangeSubset"); } else if (field.getAxisSubset().size() == 0) return; AxisSubsetType axisSubset = (AxisSubsetType) field.getAxisSubset().get(0); final String axisId = axisSubset.getIdentifier(); if (!axisId.equalsIgnoreCase("Bands"))
public Object visit(ASTFieldSubset node, Object data) { FieldSubsetType fs = wcsf.createFieldSubsetType(); for (int i = 0; i < node.jjtGetNumChildren(); i++) { Node child = node.jjtGetChild(i); if (child instanceof ASTFieldId) { CodeType id = owsf.createCodeType(); id.setValue((String) child.jjtAccept(this, null)); fs.setIdentifier(id); } else if (child instanceof ASTInterpolation) { fs.setInterpolationType((String) child.jjtAccept(this, null)); } else if (child instanceof ASTAxisSubset) { fs.getAxisSubset().add(child.jjtAccept(this, null)); } } return fs; }
RangeSubsetType rs = getCoverage.getRangeSubset(); FieldSubsetType field = (FieldSubsetType) rs.getFieldSubset().get(0); AxisSubsetType axis = (AxisSubsetType) field.getAxisSubset().get(0); List keys = axis.getKey(); assertEquals(1, rs.getFieldSubset().size()); assertEquals("BlueMarble", field.getIdentifier().getValue()); assertEquals(1, field.getAxisSubset().size()); assertEquals("Red_band", keys.get(0)); assertEquals(field.getInterpolationType(), interpolation);
interpolationType = field.getInterpolationType(); if (field.getAxisSubset().size() > 1) { throw new WcsException("Multi axis coverages are not supported yet"); if (field.getAxisSubset().size() == 1) { AxisSubsetType axisSubset = (AxisSubsetType) field.getAxisSubset().get(0); List keys = axisSubset.getKey(); int[] bands = new int[keys.size()]; if (index == null) throw new WcsException("Unknown field/axis/key combination " + field.getIdentifier().getValue() + "/" + axisSubset.getIdentifier() + "/" + key); bands[j] = index;
assertEquals(1, gc.getRangeSubset().getFieldSubset().size()); FieldSubsetType field = (FieldSubsetType) gc.getRangeSubset().getFieldSubset().get(0); assertEquals("BlueMarble", field.getIdentifier().getValue()); assertEquals("bicubic", field.getInterpolationType()); assertEquals(1, field.getAxisSubset().size()); AxisSubsetType axis = (AxisSubsetType) field.getAxisSubset().get(0); assertEquals("Bands", axis.getIdentifier()); assertEquals(1, axis.getKey().size());
interpolationType = field.getInterpolationType(); if (field.getAxisSubset().size() > 1) { throw new WcsException("Multi axis coverages are not supported yet"); if (field.getAxisSubset().size() == 1) { AxisSubsetType axisSubset = (AxisSubsetType) field.getAxisSubset().get(0); List keys = axisSubset.getKey(); int[] bands = new int[keys.size()]; throw new WcsException( "Unknown field/axis/key combination " + field.getIdentifier().getValue() + "/" + axisSubset.getIdentifier()