si.uom.NonSI Java Examples

The following examples show how to use si.uom.NonSI. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenderPanelImpl.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Expand envelope.
 *
 * @param bounds the bounds
 */
private void expandEnvelope(ReferencedEnvelope bounds) {
    Unit<?> unit =
            CRSUtilities.getUnit(bounds.getCoordinateReferenceSystem().getCoordinateSystem());

    double width;
    double height;
    if (unit == NonSI.DEGREE_ANGLE) {
        width =
                (bounds.getWidth() < BOUNDINGBOX_BUFFER_THRESHOLD_ANGLE)
                        ? BOUNDINGBOX_BUFFER_MIN_ANGLE
                        : (bounds.getWidth() * BOUNDINGBOX_BUFFER_ANGLE);
        height =
                (bounds.getHeight() < BOUNDINGBOX_BUFFER_THRESHOLD_ANGLE)
                        ? BOUNDINGBOX_BUFFER_MIN_ANGLE
                        : (bounds.getHeight() * BOUNDINGBOX_BUFFER_ANGLE);
    } else {
        width =
                (bounds.getWidth() < BOUNDINGBOX_BUFFER_THRESHOLD_LINEAR)
                        ? BOUNDINGBOX_BUFFER_MIN_LINEAR
                        : (bounds.getWidth() * BOUNDINGBOX_BUFFER_LINEAR);
        height =
                (bounds.getHeight() < BOUNDINGBOX_BUFFER_THRESHOLD_LINEAR)
                        ? BOUNDINGBOX_BUFFER_MIN_LINEAR
                        : (bounds.getHeight() * BOUNDINGBOX_BUFFER_LINEAR);
    }

    bounds.expandBy(width, height);
}
 
Example #2
Source File: GeometryUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static Unit<Length> lookup(final String name) {
  final String lowerCaseName = name.toLowerCase();

  Unit<Length> unit = lookup(SI.class, lowerCaseName);
  if (unit != null) {
    return unit;
  }

  unit = lookup(NonSI.class, lowerCaseName);
  if (unit != null) {
    return unit;
  }

  if (lowerCaseName.endsWith("s")) {
    return lookup(lowerCaseName.substring(0, lowerCaseName.length() - 1));
  }
  if (lowerCaseName.startsWith("kilo") && (lowerCaseName.length() > 4)) {
    final Unit<Length> u = lookup(lowerCaseName.substring(4));
    if (u != null) {
      return u.multiply(1000);
    }
  }
  // if we get here, try some aliases
  if (lowerCaseName.equals("feet")) {
    return USCustomary.FOOT;
  }
  // if we get here, try some aliases
  if (lowerCaseName.equals("meter")) {
    return Units.METRE;
  }
  if (lowerCaseName.equals("unity")) {
    return (Unit) AbstractUnit.ONE;
  }
  return null;
}