/** * @param other * @param convert * if true the intervals and singlevalues of this instance will be converted to the type of the given * axis subset if their names match and if this type is unknown (void). * @return true if this {@link AxisSubset} matches the given AxisSubset, e.g. if the names are equal and the axis * values have matching parameters in the given one. */ public boolean match( AxisSubset other, boolean convert ) { boolean result = other.getName().equalsIgnoreCase( name ); if ( result ) { if ( this.type == ValueType.Void && convert ) { convertTypes( other.getType() ); } boolean ic = checkIntervals( other.getIntervals() ); boolean sc = checkSingles( other.getSingleValues(), other.getIntervals() ); result = ic && sc; } return result; }
private boolean rangeSetsAreApplicable( RangeSet configuredRangeSet, RangeSet requestedRangeSet ) { List<AxisSubset> reqAxis = requestedRangeSet.getAxisDescriptions(); List<AxisSubset> checked = new ArrayList<AxisSubset>( reqAxis ); for ( AxisSubset ras : reqAxis ) { if ( ras.getName() != null ) { boolean hasMatch = false; Iterator<AxisSubset> it = configuredRangeSet.getAxisDescriptions().iterator(); while ( it.hasNext() && !hasMatch ) { AxisSubset as = it.next(); if ( as.getName().equalsIgnoreCase( ras.getName() ) ) { if ( ras.match( as, true ) ) { // delete the one in checked checked.remove( ras ); } else { return false; } } } } } return checked.isEmpty(); }
/** * @param name * @param label * may be <code>null</code>, in this case the name will be returned as label. * @param intervals * @param singleValues */ public AxisSubset( String name, String label, List<Interval<?, ?>> intervals, List<SingleValue<?>> singleValues ) { this.name = name; this.label = label; this.intervals = intervals; this.singleValues = singleValues; ValueType tmpType = determineType( intervals ); if ( tmpType == null ) { tmpType = determineTypeFromSingles( singleValues ); } this.type = tmpType == null ? ValueType.Void : tmpType; }
/** * @param writer * @param axisDescriptions * @throws XMLStreamException */ protected static void exportAxisDescriptions( XMLStreamWriter writer, List<AxisSubset> axisDescriptions ) throws XMLStreamException { if ( !axisDescriptions.isEmpty() ) { for ( AxisSubset ass : axisDescriptions ) { if ( ass != null ) { writer.writeStartElement( WCS_100_NS, "axisDescription" ); writer.writeStartElement( WCS_100_NS, "AxisDescription" ); writeElement( writer, WCS_100_NS, "name", ass.getName() ); writeElement( writer, WCS_100_NS, "label", ass.getLabel() ); writer.writeStartElement( WCS_100_NS, "values" ); exportIntervals( writer, ass.getIntervals() ); if ( ass.getSingleValues() != null ) { for ( SingleValue<?> sv : ass.getSingleValues() ) { exportSingleValueType( writer, sv, "singleValue" ); } } writer.writeEndElement();// WCS_100_NS, "values" ); writer.writeEndElement();// WCS_100_NS, "AxisDescription" ); writer.writeEndElement();// WCS_100_NS, "axisDescription" ); } } } }
axis.add( new AxisSubset( axisName, null, intervals, singleValues ) );
/** * @param axisSubset */ @SuppressWarnings("unchecked") private <T extends Comparable<T>> boolean isValid( T value, AxisSubset axisSubset ) { List<Interval<?, ?>> intervals = axisSubset.getIntervals(); List<SingleValue<?>> singleValues = axisSubset.getSingleValues(); boolean isValid = false; if ( intervals != null && !intervals.isEmpty() ) { Iterator<Interval<?, ?>> it = intervals.iterator(); while ( it.hasNext() && !isValid ) { try { isValid = ( (Interval<T, ?>) it.next() ).liesWithin( value ); } catch ( ClassCastException cc ) { // mmm, this should never happen, but just to make sure. } } } if ( !isValid && singleValues != null && !singleValues.isEmpty() ) { Iterator<SingleValue<?>> it = singleValues.iterator(); while ( it.hasNext() && !isValid ) { try { isValid = ( (SingleValue<T>) it.next() ).value.equals( value ); } catch ( ClassCastException cc ) { // mmm, this should never happen, but just to make sure. } } } return isValid; }
private Map<BandType, AxisSubset> getReferencedBands( List<AxisSubset> requestedAxis ) { List<AxisSubset> copyRA = new ArrayList<AxisSubset>( requestedAxis ); Map<BandType, AxisSubset> bands = new HashMap<BandType, AxisSubset>( requestedAxis.size() ); for ( AxisSubset ras : requestedAxis ) { String name = ras.getName(); if ( ras.getName() != null && !"".equals( ras.getName() ) ) { BandType refBand = BandType.fromString( name ); if ( refBand != null ) { bands.put( refBand, ras ); copyRA.remove( ras ); } } } if ( !bands.isEmpty() ) { requestedAxis.removeAll( copyRA ); return bands; } return null; }
ops.add( new AxisSubset( BAND_0.name(), null, intervals, singleValues ) );
ass.add( new AxisSubset( ad.getName(), ad.getLabel(), intervals, singleValues ) );
List<AxisSubset> reqAxis = requestedRangeSet.getAxisDescriptions(); for ( AxisSubset ras : reqAxis ) { if ( ras.getName() != null ) { boolean hasMatch = false; Iterator<AxisSubset> it = configuredRangeSet.getAxisDescriptions().iterator(); if ( as.getName().equalsIgnoreCase( ras.getName() ) ) { boolean match = false; try { match = ras.match( as, true ); } catch ( NumberFormatException e ) { throw new OWSException( "Following rangeset: " + ras.getName() + " has an AxisDescriptions requesting a value which is not valid for the requested coverage", OWSException.INVALID_PARAMETER_VALUE ); throw new OWSException( "Following rangeset: " + ras.getName() + " has an AxisDescriptions requesting a value which is not valid for the requested coverage", OWSException.INVALID_PARAMETER_VALUE );
axisSubsets.add( new AxisSubset( name, null, intervals, singleValues ) );
axis.add( new AxisSubset( name, label, val, null ) );