List of usage examples for java.math BigDecimal floatValue
@Override public float floatValue()
From source file:org.apache.openjpa.jdbc.sql.HSQLDictionary.java
@Override public void setBigDecimal(PreparedStatement stmnt, int idx, BigDecimal val, Column col) throws SQLException { // hsql can't compare a BigDecimal equal to any other type, so try // to set type based on column int type = (val == null || col == null) ? JavaTypes.BIGDECIMAL : col.getJavaType(); switch (type) { case JavaTypes.DOUBLE: case JavaTypes.DOUBLE_OBJ: setDouble(stmnt, idx, val.doubleValue(), col); break;/*from w w w . j a va 2 s .c om*/ case JavaTypes.FLOAT: case JavaTypes.FLOAT_OBJ: setDouble(stmnt, idx, val.floatValue(), col); break; default: super.setBigDecimal(stmnt, idx, val, col); } }
From source file:org.openvpms.component.system.common.jxpath.OpenVPMSTypeConverter.java
/** * Convert a {@link BigDecimal} to another type * /*from w w w.j ava 2 s .co m*/ * @param type * the class to convert too * @param value * the value to convert * @return Number * the converted number of null. * */ protected Number allocateNumber(Class type, BigDecimal value) { if (type == Byte.class || type == byte.class) { return new Byte(value.byteValue()); } if (type == Short.class || type == short.class) { return new Short(value.shortValue()); } if (type == Integer.class || type == int.class) { return new Integer(value.intValue()); } if (type == Long.class || type == long.class) { return new Long(value.longValue()); } if (type == Float.class || type == float.class) { return new Float(value.floatValue()); } if (type == Double.class || type == double.class) { return new Double(value.doubleValue()); } if (type == BigDecimal.class) { return value; } if (type == BigInteger.class) { return BigInteger.valueOf(value.longValue()); } if (type == Money.class) { return new Money((BigDecimal) value); } return null; }
From source file:org.apache.openjpa.jdbc.sql.SolidDBDictionary.java
@Override public void setBigDecimal(PreparedStatement stmnt, int idx, BigDecimal val, Column col) throws SQLException { int type = (val == null || col == null) ? JavaTypes.BIGDECIMAL : col.getJavaType(); switch (type) { case JavaTypes.DOUBLE: case JavaTypes.DOUBLE_OBJ: setDouble(stmnt, idx, val.doubleValue(), col); break;/*from ww w .j a v a2 s .co m*/ case JavaTypes.FLOAT: case JavaTypes.FLOAT_OBJ: setFloat(stmnt, idx, val.floatValue(), col); break; case JavaTypes.LONG: case JavaTypes.LONG_OBJ: setLong(stmnt, idx, val.longValue(), col); break; default: super.setBigDecimal(stmnt, idx, val, col); } }
From source file:au.org.ala.delta.editor.slotfile.directive.DirOutDefault.java
private void writeKeyStates(MutableDeltaDataSet dataSet, DirectiveArguments directiveArgs) { int prevNo;/*w w w . java 2 s . co m*/ int curNo; List<DirectiveArgument<?>> args; List<Integer> data; // The comparison function will sort all the key states, grouping // all those belonging to a single character, sorted in order by // there pseudo-value. args = directiveArgs.getDirectiveArguments(); Collections.sort(args); prevNo = 0; for (DirectiveArgument<?> vectIter : directiveArgs.getDirectiveArguments()) { au.org.ala.delta.model.Character charBase = dataSet.getCharacter((Integer) vectIter.getId()); CharacterType charType = charBase.getCharacterType(); curNo = charBase.getCharacterId(); if (curNo != prevNo) { _textBuffer.append(" ").append(curNo).append(","); prevNo = curNo; } else _textBuffer.append('/'); switch (charType) { case UnorderedMultiState: data = vectIter.getDataList(); Collections.sort(data); for (int j = 0; j < data.size(); j++) { if (j != 0) _textBuffer.append('&'); _textBuffer.append(data.get(j)); } break; case OrderedMultiState: { data = vectIter.getDataList(); int loState, hiState, aState; if (data.size() < 2) throw new RuntimeException("ED_INTERNAL_ERROR"); aState = data.get(0); hiState = data.get(1); loState = Math.min(aState, hiState); hiState = Math.max(aState, hiState); _textBuffer.append(loState); if (hiState > loState) { _textBuffer.append('-'); _textBuffer.append(hiState); } } break; case IntegerNumeric: case RealNumeric: { List<BigDecimal> bigDecimals = vectIter.getData(); BigDecimal loNumb, hiNumb; if (bigDecimals.size() < 2) throw new RuntimeException("ED_INTERNAL_ERROR"); loNumb = bigDecimals.get(0); hiNumb = bigDecimals.get(1); if (loNumb.floatValue() == -Float.MAX_VALUE) _textBuffer.append('~'); else { _textBuffer.append(loNumb.toPlainString()); } if (hiNumb.floatValue() == Float.MAX_VALUE) _textBuffer.append('~'); else if (loNumb.compareTo(hiNumb) < 0) { if (!(loNumb.floatValue() == -Float.MAX_VALUE)) _textBuffer.append('-'); _textBuffer.append(hiNumb.toPlainString()); } } break; default: throw new RuntimeException("ED_INAPPROPRIATE_TYPE"); // break; } } }
From source file:com.shared.rides.service.ProfileService.java
public boolean calculateRating(long requestUserID, long userID, int profile, int rating) { User u = userDAO.load(userID);/*from w w w . j a va2 s. c om*/ // User requestUser = userDAO.load(requestUserID); // boolean isValidate = false; /* * Primero voy a ver si la asociacion entre las dos personas es mayor a * 21 dias (3 semanas), para permitir que la persona puede puntuar */ /* * Date actualDate = new Date(); List<Association> assocList = * requestUser.getAssociations(); List<Association> myRequestsList = * userDAO.getMyRequests(requestUser); * * for (int i = 0; i < assocList.size(); i++){ User assocUser = * assocList.get(i).getApplicantID(); if (assocUser.getUserId() == * userID && assocList.get(i).getState().equals(State.ACCEPTED)){ int * diff = (int) ((assocList.get(i).getDate().getTime() - * actualDate.getTime()) / (24 * 60 * 60 * 1000)); if (diff > 21){ * isValidate = true; break; } } } for (int j = 0; j < * myRequestsList.size(); j++){ //Obtengo el id del usuario al cual le * envie la peticion long userAssocId = * assocDAO.getSupplierId(myRequestsList.get(j)); if (userID == * userAssocId && * myRequestsList.get(j).getState().equals(State.ACCEPTED)){ int diff = * (int) ((assocList.get(j).getDate().getTime() - actualDate.getTime()) * / (24 * 60 * 60 * 1000)); if (diff > 21){ isValidate = true; break; } * } } */ // if(isValidate){ BigDecimal value; if (profile == 0) { float auxRating = u.getPedestrian().getRating(); auxRating = (auxRating + rating) / 2; u.getPedestrian().setRating(Math.round(auxRating * 100) / 100); } else { float auxRating = u.getDriver().getRating(); auxRating = (auxRating + rating) / 2; value = new BigDecimal(String.valueOf(auxRating)).setScale(2, BigDecimal.ROUND_FLOOR); u.getDriver().setRating(value.floatValue()); } userDAO.update(u); return true; // } // return false; }
From source file:de.undercouch.bson4jackson.BsonGenerator.java
@Override public void writeNumber(BigDecimal dec) throws IOException, JsonGenerationException { if (isEnabled(Feature.WRITE_BIGDECIMALS_AS_STRINGS)) { writeString(dec.toString());/*from w w w. j a va 2s . co m*/ return; } float f = dec.floatValue(); if (!Float.isInfinite(f)) { writeNumber(f); } else { double d = dec.doubleValue(); if (!Double.isInfinite(d)) { writeNumber(d); } else { writeString(dec.toString()); } } }
From source file:org.sejda.impl.pdfbox.component.PdfHeaderFooterWriter.java
public void writeFooter(SetHeaderFooterParameters parameters) throws TaskIOException { PDFont font = defaultIfNull(getStandardType1Font(parameters.getFont()), PDType1Font.HELVETICA); BigDecimal fontSize = defaultIfNull(parameters.getFontSize(), BigDecimal.TEN); HorizontalAlign horAlignment = defaultIfNull(parameters.getHorizontalAlign(), HorizontalAlign.CENTER); VerticalAlign verAlignment = defaultIfNull(parameters.getVerticalAlign(), VerticalAlign.BOTTOM); SortedSet<Integer> pages = parameters.getPageRange().getPages(documentHandler.getNumberOfPages()); LOG.debug("Found {} pages to apply header or footer", pages.size()); Integer labelPageNumber = parameters.getNumbering().getLogicalPageNumber(); for (Integer pageNumber : pages) { String label = parameters.styledLabelFor(labelPageNumber); PDPage page = documentHandler.getPage(pageNumber); PDRectangle pageSize = page.findCropBox(); try {//from www . j a va2s .c om float stringWidth = font.getStringWidth(label) * fontSize.floatValue() / 1000f; float xPosition = horAlignment.position(pageSize.getWidth(), stringWidth, DEFAULT_MARGIN); float yPosition = verAlignment.position(pageSize.getHeight(), DEFAULT_MARGIN); PDPageContentStream contentStream = new PDPageContentStream( documentHandler.getUnderlyingPDDocument(), page, true, true); contentStream.beginText(); contentStream.setFont(font, fontSize.floatValue()); contentStream.moveTextPositionByAmount(xPosition, yPosition); contentStream.drawString(label); contentStream.endText(); contentStream.close(); } catch (IOException e) { throw new TaskIOException("An error occurred writing the header or footer of the page.", e); } labelPageNumber++; } }
From source file:com.salesmanager.core.module.impl.application.prices.MonthlyPriceModule.java
public OrderTotalSummary calculateOrderPrice(Order order, OrderTotalSummary orderSummary, OrderProduct orderProduct, OrderProductPrice productPrice, String currency, Locale locale) { /**// ww w.j a v a 2s. com * Monthly price goes in the oneTime fees as well as in the upcoming * recursive fees */ BigDecimal finalPrice = null; BigDecimal discountPrice = null; BigDecimal originalPrice = orderProduct.getOriginalProductPrice(); if (!productPrice.isDefaultPrice()) { originalPrice = productPrice.getProductPriceAmount(); } int quantity = orderProduct.getProductQuantity(); // the real price is the price submited finalPrice = orderProduct.getProductPrice(); finalPrice = finalPrice.multiply(new BigDecimal(quantity)); // the final price is the product price * quantity if (finalPrice == null) {// pick it from the productPrice finalPrice = productPrice.getProductPriceAmount(); finalPrice = finalPrice.multiply(new BigDecimal(quantity)); } // this type of price needs an upfront payment BigDecimal otprice = orderSummary.getOneTimeSubTotal(); if (otprice == null) { otprice = new BigDecimal(0); } otprice = otprice.add(finalPrice); orderSummary.setOneTimeSubTotal(otprice); ProductPriceSpecial pps = productPrice.getSpecial(); // Build text StringBuffer notes = new StringBuffer(); notes.append(quantity).append(" x "); notes.append(orderProduct.getProductName()); notes.append(" "); if (!productPrice.isDefaultPrice()) { notes.append( CurrencyUtil.displayFormatedAmountWithCurrency(productPrice.getProductPriceAmount(), currency)); } else { notes.append(CurrencyUtil.displayFormatedAmountWithCurrency(orderProduct.getProductPrice(), currency)); } notes.append(" "); notes.append(this.getPriceSuffixText(currency, locale)); if (pps != null) { if (pps.getProductPriceSpecialStartDate() != null && pps.getProductPriceSpecialEndDate() != null) { if (pps.getProductPriceSpecialStartDate().before(order.getDatePurchased()) && pps.getProductPriceSpecialEndDate().after(order.getDatePurchased())) { BigDecimal dPrice = new BigDecimal(ProductUtil.determinePrice(productPrice).floatValue()); BigDecimal subTotal = originalPrice.multiply(new BigDecimal(orderProduct.getProductQuantity())); BigDecimal creditSubTotal = pps.getProductPriceSpecialAmount() .multiply(new BigDecimal(orderProduct.getProductQuantity())); BigDecimal credit = subTotal.subtract(creditSubTotal); if (dPrice.floatValue() < productPrice.getProductPriceAmount().floatValue()) { discountPrice = productPrice.getProductPriceAmount().subtract(dPrice); BigDecimal newPrice = orderProduct.getProductPrice(); if (!productPrice.isDefaultPrice()) { newPrice = productPrice.getProductPriceAmount(); } else { newPrice = newPrice.add(discountPrice); } StringBuffer spacialNote = new StringBuffer(); spacialNote.append("<font color=\"red\">["); spacialNote.append(orderProduct.getProductName()); spacialNote.append(" "); spacialNote.append(CurrencyUtil.displayFormatedAmountWithCurrency(credit, currency)); spacialNote.append(" "); spacialNote.append(LabelUtil.getInstance().getText(locale, "label.generic.rebate")); spacialNote.append(" "); spacialNote.append(LabelUtil.getInstance().getText(locale, "label.generic.until")); spacialNote.append(" "); spacialNote.append(DateUtil.formatDate(pps.getProductPriceSpecialEndDate())); spacialNote.append("]</font>"); OrderTotalLine line = new OrderTotalLine(); // BigDecimal credit = discountPrice; line.setText(spacialNote.toString()); line.setCost(credit); line.setCostFormated(CurrencyUtil.displayFormatedAmountWithCurrency(credit, currency)); orderSummary.addDueNowCredits(line); orderSummary.addRecursiveCredits(line); BigDecimal oneTimeCredit = orderProduct.getApplicableCreditOneTimeCharge(); oneTimeCredit = oneTimeCredit.add(credit); orderProduct.setApplicableCreditOneTimeCharge(oneTimeCredit); } } else if (pps.getProductPriceSpecialDurationDays() > -1) { Date dt = new Date(new Date().getTime()); int numDays = pps.getProductPriceSpecialDurationDays(); Date purchased = order.getDatePurchased(); Calendar c = Calendar.getInstance(); c.setTime(dt); c.add(Calendar.DATE, numDays); BigDecimal dPrice = new BigDecimal(ProductUtil.determinePrice(productPrice).floatValue()); if (dt.before(c.getTime()) && dPrice.floatValue() < productPrice.getProductPriceAmount().floatValue()) { discountPrice = productPrice.getProductPriceAmount().subtract(dPrice); BigDecimal newPrice = orderProduct.getProductPrice(); BigDecimal subTotal = originalPrice .multiply(new BigDecimal(orderProduct.getProductQuantity())); BigDecimal creditSubTotal = pps.getProductPriceSpecialAmount() .multiply(new BigDecimal(orderProduct.getProductQuantity())); BigDecimal credit = subTotal.subtract(creditSubTotal); if (!productPrice.isDefaultPrice()) { newPrice = productPrice.getProductPriceAmount(); } else { newPrice = newPrice.add(discountPrice); } StringBuffer spacialNote = new StringBuffer(); spacialNote.append("<font color=\"red\">["); spacialNote.append(orderProduct.getProductName()); spacialNote.append(" "); spacialNote.append(CurrencyUtil.displayFormatedAmountWithCurrency(credit, currency)); spacialNote.append(" "); spacialNote.append(LabelUtil.getInstance().getText(locale, "label.generic.rebate")); spacialNote.append(" "); spacialNote.append(LabelUtil.getInstance().getText(locale, "label.generic.until")); spacialNote.append(" "); spacialNote.append(DateUtil.formatDate(c.getTime())); spacialNote.append("]</font>"); OrderTotalLine line = new OrderTotalLine(); line.setText(spacialNote.toString()); line.setCost(credit); line.setCostFormated(CurrencyUtil.displayFormatedAmountWithCurrency(credit, currency)); orderSummary.addDueNowCredits(line); if (numDays > 30) { orderSummary.addRecursiveCredits(line); } BigDecimal oneTimeCredit = orderProduct.getApplicableCreditOneTimeCharge(); oneTimeCredit = oneTimeCredit.add(credit); orderProduct.setApplicableCreditOneTimeCharge(oneTimeCredit); // } } } } } BigDecimal newPrice = orderProduct.getProductPrice(); if (!productPrice.isDefaultPrice()) { newPrice = productPrice.getProductPriceAmount(); } newPrice = newPrice.multiply(new BigDecimal(quantity)); // Recursive sub total BigDecimal rprice = orderSummary.getRecursiveSubTotal(); if (rprice == null) { rprice = new BigDecimal(0); } // recursive always contain full price rprice = rprice.add(newPrice); orderSummary.setRecursiveSubTotal(rprice); // recursive price OrderTotalLine scl = new OrderTotalLine(); scl.setText(notes.toString()); scl.setCost(newPrice); scl.setCostFormated(CurrencyUtil.displayFormatedAmountWithCurrency(newPrice, currency)); orderSummary.addRecursivePrice(scl); return orderSummary; }
From source file:org.apache.torque.oid.IDBroker.java
/** * Check the frequency of retrieving new ids from the database. * If the frequency is high then we increase the amount (i.e. * quantity column) of ids retrieved on each access. Tries to * alter number of keys grabbed so that IDBroker retrieves a new * set of ID's prior to their being needed. * * @param tableName The name of the table for which we want an id. *//*w w w.j a v a 2s . co m*/ private void checkTiming(String tableName) { // Check if quantity changing is switched on. // If prefetch is turned off, changing quantity does not make sense if (!configuration.getBoolean(DB_IDBROKER_CLEVERQUANTITY, true) || !configuration.getBoolean(DB_IDBROKER_PREFETCH, true)) { return; } // Get the last id request for this table. java.util.Date lastTime = lastQueryTime.get(tableName); java.util.Date now = new java.util.Date(); if (lastTime != null) { long thenLong = lastTime.getTime(); long nowLong = now.getTime(); long timeLapse = nowLong - thenLong; log.debug("checkTiming(): sleep time was " + timeLapse + " milliseconds for table " + tableName); if (timeLapse < SLEEP_PERIOD) { log.debug("checkTiming(): Unscheduled retrieval of ids " + "for table " + tableName); // Increase quantity, so that hopefully this does not // happen again. BigDecimal quantity = getQuantity(tableName, null); double newQuantity; if (timeLapse > 0) { float rate = quantity.floatValue() / timeLapse; newQuantity = Math.ceil(SLEEP_PERIOD * rate * SAFETY_MARGIN); log.debug("checkTiming(): calculated new quantity " + newQuantity + " from rate " + rate); } else { // time lapse is so small that it was not measurable // use factor 2 newQuantity = quantity.floatValue() * 2; log.debug("checkTiming(): calculated new quantity " + newQuantity + " from double the old quantity (time lapse 0)"); } Double maxQuantity = configuration.getDouble(DB_IDBROKER_CLEVERQUANTITY_MAX, CLEVERQUANTITY_MAX_DEFAULT); if (maxQuantity != null && newQuantity > maxQuantity) { if (quantity.doubleValue() > maxQuantity) { // do not decrease quantity value; newQuantity = quantity.doubleValue(); } else { newQuantity = maxQuantity; } } quantityStore.put(tableName, new BigDecimal(newQuantity)); log.debug("checkTiming(): new quantity " + newQuantity + " stored in quantity store (not in db)"); } } lastQueryTime.put(tableName, now); }
From source file:petascope.wcs2.extensions.AbstractFormatExtension.java
/** * Update m with the correct bounds and axes (mostly useful when there is slicing/trimming in the request) * * @param request//from w w w .ja v a 2 s . c o m * @param m * @param dbMeta * @throws PetascopeException * @throws SecoreException * @throws WCSException */ protected void updateGetCoverageMetadata(GetCoverageRequest request, GetCoverageMetadata m, DbMetadataSource dbMeta) throws PetascopeException, SecoreException, WCSException { // Init variables, to be then filled scanning the request subsets. // Grid axis labels, and grid bounds : grid (rasdaman) order Map<Integer, String> axesLabels = new TreeMap<Integer, String>(); String lowerCellDom = ""; String upperCellDom = ""; // Tuples of external CRS bounds : CRS order // Create a key-ordered map {axisLabel->dom} so that the correct order can be reconstructed automatically. Map<Integer, String> lowerDom = new TreeMap<Integer, String>(); Map<Integer, String> upperDom = new TreeMap<Integer, String>(); // Same as lowerDom/upperDom but forcing easting first, for GIS binary formats encoding. String lowerGisDom = ""; String upperGisDom = ""; // CRS need to be sliced accordingly upon dimension slicings String crsName; Set<String> slicedAxes = new HashSet<String>(); // miscellanea CoverageMetadata meta = m.getMetadata(); boolean domUpdated; Iterator<DomainElement> domsIt = meta.getDomainIterator(); Iterator<CellDomainElement> cellDomsIt = meta.getCellDomainIterator(); DomainElement domainEl; CellDomainElement cellDomainEl; List<DimensionSubset> subsList = request.getSubsets(); // NOTE: single loop since still N=M for Petascope, being N = dim(grid) and M=dim(CRS). // Keep domainElement order (grid order), but need to re-order the coordinates in the tuple for lowerDom/upperDom while (domsIt.hasNext()) { // Check if one subset trims on /this/ dimension: // Order and quantity of subsets not necessarily coincide with domain of the coverage // (e.g. single subset on Y over a nD coverage) domUpdated = false; domainEl = domsIt.next(); cellDomainEl = cellDomsIt.next(); // Loop through each subsets in the request and check if this axis is involved Iterator<DimensionSubset> subsIt = subsList.iterator(); DimensionSubset subset; while (subsIt.hasNext()) { subset = subsIt.next(); if (subset.getDimension().equals(domainEl.getLabel())) { try { // Compare subset with domain borders and update if (subset instanceof DimensionTrim) { // Replace asterisks and fetch subset bounds stars2bounds((DimensionTrim) subset, domainEl); String trimLow = ((DimensionTrim) subset).getTrimLow(); String trimHigh = ((DimensionTrim) subset).getTrimHigh(); // Append axis/uom label axesLabels.put(CrsUtil.getCrsAxisOrder(meta.getCrsUris(), domainEl.getLabel()), subset.getDimension()); // Append updated bounds // TODO: if request is specified via grid coords, need a backwards transform here // {cellDomain->domain} to show domain values in the WCS response: // Crs.convertToDomainCoords() if (trimLow.contains("\"")) { // Convert timestamp to temporal numeric coordinate String datumOrigin = domainEl.getAxisDef().getCrsDefinition().getDatumOrigin(); trimLow = "" + (TimeUtil.countOffsets(datumOrigin, trimLow, domainEl.getUom(), 1D)); // do not normalize by vector here: absolute time coords needed } String lower = new BigDecimal( Math.max(Double.parseDouble(trimLow), domainEl.getMinValue().doubleValue())) .toPlainString(); // align with sample space of grid points: lower = WcsUtil.fitToSampleSpace(lower, domainEl, false); lowerGisDom += lower + " "; // The map is automatically sorted by key value (axis order in the CRS definition) lowerDom.put(CrsUtil.getCrsAxisOrder(meta.getCrsUris(), domainEl.getLabel()), lower); if (trimHigh.contains("\"")) { // Convert timestamp to temporal numeric coordinate String datumOrigin = domainEl.getAxisDef().getCrsDefinition().getDatumOrigin(); String stringHi = trimHigh; trimHigh = "" + (TimeUtil.countOffsets(datumOrigin, stringHi, domainEl.getUom(), 1D)); // do not normalize by vector here: absolute time coords needed } String upper = new BigDecimal( Math.min(Double.parseDouble(trimHigh), domainEl.getMaxValue().doubleValue())) .toPlainString(); // align with sample space of grid points: upper = WcsUtil.fitToSampleSpace(upper, domainEl, true); upperGisDom += upper + " "; // The map is automatically sorted by key value (axis order in the CRS definition) upperDom.put(CrsUtil.getCrsAxisOrder(meta.getCrsUris(), domainEl.getLabel()), upper); // Append updated pixel bounds String decimalsExp = "\\.[0-9]+"; long[] cellDom = (CrsUtil.GRID_CRS.equals(subset.getCrs()) || // : subset=x,CRS:1(x1,x2) || subsettingCrs=CRS:1 m.getCoverageType().equals(XMLSymbols.LABEL_GRID_COVERAGE)) ? new long[] { // NOTE: e.g. parseInt("10.0") throws exception: need to remove decimals. Integer.parseInt(trimLow.replaceAll(decimalsExp, "").trim()), Integer.parseInt(trimHigh.replaceAll(decimalsExp, "").trim()) } // subsets are already grid indexes : CrsUtil.convertToInternalGridIndices(m.getMetadata(), dbMeta, domainEl.getLabel(), trimLow, !trimLow.matches(QUOTED_SUBSET), trimHigh, !trimHigh.matches(QUOTED_SUBSET)); // If SCALING on this dimension, fix upperCellDom and offset vector by scale factor if (request.isScaled()) { // SCALING EXTENSION: geometry changes Scaling scaling = request.getScaling(); String axisLabel = subset.getDimension(); if (scaling.isScaled(axisLabel)) { BigDecimal scalingFactor = ScalingExtension.computeScalingFactor(scaling, axisLabel, new BigDecimal(cellDom[0]), new BigDecimal(cellDom[1])); // update grid envelope long scaledExtent = Math.round( Math.floor((cellDom[1] - cellDom[0] + 1) / scalingFactor.floatValue())); cellDom[1] = (long) (cellDom[0] + scaledExtent - 1); // update offset vectors // [!] NOTE: do *not* use domainEl.setScalarResolution since world2pixel conversions are cached. m.setScalingFactor(axisLabel, scalingFactor); } } // In any case, properly trim the bounds by the image extremes int cellDomainElLo = cellDomainEl.getLoInt(); int cellDomainElHi = cellDomainEl.getHiInt(); lowerCellDom += (cellDomainElLo > cellDom[0]) ? cellDomainElLo + " " : cellDom[0] + " "; upperCellDom += (cellDomainElHi < cellDom[1]) ? cellDomainElHi + " " : cellDom[1] + " "; } else if (subset instanceof DimensionSlice) { log.debug("Axis " + domainEl.getLabel() + " has been sliced: remove it from the boundedBy element and track the axis for CRS slicing."); slicedAxes.add(subset.getDimension()); } else { throw new WCSException(ExceptionCode.InternalComponentError, "Subset '" + subset + "' is not recognized as trim nor slice."); } // flag: if no subset has updated the bounds, then need to append the bbox value domUpdated = true; } catch (NumberFormatException ex) { String message = "Error while casting a subset to numeric format for comparison: " + ex.getMessage(); log.error(message); throw new WCSException(ExceptionCode.InvalidRequest, message); } catch (WCSException ex) { throw ex; } } } // END subsets iterator if (!domUpdated) { // This dimension is not involved in any subset: use bbox bounds axesLabels.put(CrsUtil.getCrsAxisOrder(meta.getCrsUris(), domainEl.getLabel()), domainEl.getLabel()); lowerGisDom += BigDecimalUtil.stripDecimalZeros(domainEl.getMinValue()) + " "; upperGisDom += BigDecimalUtil.stripDecimalZeros(domainEl.getMaxValue()) + " "; // The map is automatically sorted by key value (axis order in the CRS definition) lowerDom.put(CrsUtil.getCrsAxisOrder(meta.getCrsUris(), domainEl.getLabel()), BigDecimalUtil.stripDecimalZeros(domainEl.getMinValue()).toPlainString()); upperDom.put(CrsUtil.getCrsAxisOrder(meta.getCrsUris(), domainEl.getLabel()), BigDecimalUtil.stripDecimalZeros(domainEl.getMaxValue()).toPlainString()); // SCALING: geometry changes long loCellDom = cellDomainEl.getLoInt(); long hiCellDom = cellDomainEl.getHiInt(); Scaling scaling = request.getScaling(); String axisLabel = domainEl.getLabel(); if (scaling.isScaled(axisLabel)) { BigDecimal scalingFactor = ScalingExtension.computeScalingFactor(scaling, axisLabel, BigDecimal.valueOf(loCellDom), BigDecimal.valueOf(hiCellDom)); // update grid envelope long scaledExtent = Math .round(Math.floor((hiCellDom - loCellDom + 1) / scalingFactor.floatValue())); hiCellDom = (long) (loCellDom + scaledExtent - 1); // update offset vectors // [!] NOTE: do *not* use domainEl.setScalarResolution since world2pixel conversions are cached. m.setScalingFactor(axisLabel, scalingFactor); } if (hiCellDom < loCellDom) { lowerCellDom += hiCellDom + " "; upperCellDom += loCellDom + " "; } else { lowerCellDom += loCellDom + " "; upperCellDom += hiCellDom + " "; } } } // END domains iterator // Update axes labels m.setAxisLabels(StringUtils.join(axesLabels.values(), " ")); // Update **pixel-domain** bounds m.setLow(lowerCellDom); m.setHigh(upperCellDom); // Update **domain** bounds (GIS- and CRS-induced) m.setDomLow(ListUtil.printList(new ArrayList<String>(lowerDom.values()), " ")); m.setDomHigh(ListUtil.printList(new ArrayList<String>(upperDom.values()), " ")); m.setGisDomLow(lowerGisDom); m.setGisDomHigh(upperGisDom); // Update the **CRS** if (!slicedAxes.isEmpty()) { crsName = CrsUtil.sliceAxesOut(meta.getCrsUris(), slicedAxes); m.setCrs(crsName); } if (request.hasRangeSubsetting()) { // RANGE TYPE update m.setRangeFields(request.getRangeSubset().getSelectedComponents()); } }