@Override public boolean canConvert( IUnit other ) { return getReferencedObject().canConvert( other ); }
/** * @param longitude * @param units */ public void setLongitude( double longitude, IUnit units ) { this.longitude = units.convert( longitude, Unit.RADIAN ); }
/** * Check if amount of the specified unit can be converted into amount of this unit. * * @param other * @return true if this unit can be converted into the other unit */ public boolean canConvert( final IUnit other ) { return ( baseType == other.getBaseType() ) || ( baseType != null && baseType.equals( other.getBaseType() ) ); }
if ( !secondUnit.canConvert( unit ) ) { throw new XMLParsingException( adapter, param, "Ellispoid axis can only contain comparable unit, supplied are: " value = secondUnit.convert( value, unit );
IUnit targetUnit = targetAxis.getUnits(); if ( !( Unit.RADIAN.equals( targetUnit ) || Unit.METRE.equals( targetUnit ) ) ) { if ( !( targetUnit.canConvert( Unit.RADIAN ) || targetUnit.canConvert( Unit.METRE ) ) ) { throw new TransformationException( Messages.getMessage( result.setIdentity(); result.setElement( i, i, invert ? 1d / targetUnit.getScale() : targetUnit.getScale() );
if ( unit != null && !unit.isBaseType() ) { value = unit.toBaseUnits( value );
@Override public double getScale() { return getReferencedObject().getScale(); }
/** * Export a unit to xml in the crs-definitions schema layout. * * @param units * to be exported. * @param xmlWriter * to export to. * @throws XMLStreamException */ protected void export( IUnit units, XMLStreamWriter xmlWriter ) throws XMLStreamException { if ( units != null ) { xmlWriter.writeStartElement( CRSNS, "units" ); xmlWriter.writeCharacters( units.getName().toLowerCase() ); xmlWriter.writeEndElement(); } }
@Override public double toBaseUnits( double value ) { return getReferencedObject().toBaseUnits( value ); }
@Override public boolean isBaseType() { return getReferencedObject().isBaseType(); }
IUnit unit = second.first; if ( unit != null && !unit.isBaseType() ) { value = unit.toBaseUnits( value );
/** * Convert a value in this unit to the given unit if possible. * * @param value * to be converted * @param targetUnit * to convert to * @return the converted value or the same value if this unit equals given unit. * @throws IllegalArgumentException * if no conversion can be applied. */ public final double convert( final double value, final IUnit targetUnit ) { if ( this.equals( targetUnit ) ) { return value; } if ( canConvert( targetUnit ) ) { return ( value * scale ) / targetUnit.getScale(); } throw new IllegalArgumentException( "Can't convert from \"" + this + "\" to \"" + targetUnit + "\"." ); }
/** * Export a unit to xml in the crs-definitions schema layout. * * @param units * to be exported. * @param xmlWriter * to export to. * @throws XMLStreamException */ @Override protected void export( IUnit units, XMLStreamWriter xmlWriter ) throws XMLStreamException { if ( units != null ) { xmlWriter.writeStartElement( CRSNS, "Units" ); xmlWriter.writeCharacters( units.getName().toLowerCase() ); xmlWriter.writeEndElement(); } }
@Override public double convert( double value, IUnit targetUnit ) { return getReferencedObject().convert( value, targetUnit ); }
if ( !axis[i].getUnits().canConvert( Unit.METRE ) ) { throw new XMLParsingException( adapter, rootElement, "The units of all axis of a (cartesian) cs must be convertable to metres. Axis " LOG.debug( "Could not check axis [1]: " + axis[1] + " because it has no units." ); } else { if ( !( axis[0].getUnits().canConvert( Unit.RADIAN ) && axis[1].getUnits().canConvert( Unit.RADIAN ) ) ) { throw new XMLParsingException( adapter, rootElement, "The axis of the geodetic (Geographic) crs are not consistent: " LOG.debug( "Could not check axis [2]: " + axis[2] + " because it has no units." ); } else { if ( !axis[2].getUnits().canConvert( Unit.METRE ) ) { throw new XMLParsingException( adapter, rootElement, "The units of the third axis of the ellipsoidal CS type must be convertable to metre it is not: " throw new XMLParsingException( adapter, rootElement, "A vertical cs can only have 1 axis." ); if ( !axis[0].getUnits().canConvert( Unit.METRE ) ) { throw new XMLParsingException( adapter, rootElement, "The axis of the vertical crs is not convertable to metre, other values are currently not supported: "
@Override public IUnit getBaseType() { return getReferencedObject().getBaseType(); }
/** * @return the longitude value relative to the Greenwich Meridian, expressed in the radians. */ public double getLongitudeAsRadian() { return getAngularUnit().convert( getLongitude(), Unit.RADIAN ); }
double gwLongitude = adapter.getRequiredNodeAsDouble( gwLongitudeElem, new XPath( ".", nsContext ) ); IUnit unit = parseUnitOfMeasure( gwLongitudeElem ); if ( unit != null && !unit.canConvert( Unit.RADIAN ) ) { LOG.error( "The primemeridian must have RADIAN as a base unit." );
/** * @param targetUnit * The unit in which to express longitude. * @return the longitude value relative to the Greenwich Meridian, expressed in the specified units. This * convenience method make easier to obtains longitude in degrees (<code>getLongitude(Unit.DEGREE)</code>), * no matter the underlying angular unit of this prime meridian. */ public double getLongitude( final IUnit targetUnit ) { return getAngularUnit().convert( getLongitude(), targetUnit ); }
+ " does not have any axis. Hence it is invalid." ); if ( !axis[0].getUnits().canConvert( Unit.METRE ) ) { throw new ServiceInitException( "The crs with code: "