return mt.doubleValue();
}
// let's get the target unit
SingleCRS horizontalCRS = CRS.getHorizontalCRS(crs);
Unit targetUnit;
if(horizontalCRS != null) {
// leap of faith, the first axis is an horizontal one (
targetUnit = getFirstAxisUnit(horizontalCRS.getCoordinateSystem());
} else {
// leap of faith, the first axis is an horizontal one (
targetUnit = getFirstAxisUnit(crs.getCoordinateSystem());
}
if((targetUnit != null && targetUnit == NonSI.DEGREE_ANGLE) || horizontalCRS instanceof GeographicCRS || crs instanceof GeographicCRS) {
// assume we're working against a type of geographic crs, must estimate the degrees equivalent
// to the measure, we are going to use a very rough estimate (cylindrical earth model)
// TODO: maybe look at the layer bbox and get a better estimate computed at the center of the bbox
UnitConverter converter = mt.getUnit().getConverterTo(SI.METER);
double tolMeters = converter.convert(mt.doubleValue());
return tolMeters * OGC_METERS_TO_DEGREES;
} else if(targetUnit != null && targetUnit.isCompatible(SI.METER)) {
// ok, we assume the target is not a geographic one, but we might
// have to convert between meters and feet maybe
UnitConverter converter = mt.getUnit().getConverterTo(targetUnit);
return converter.convert(mt.doubleValue());
} else {