Package javax.measure.unit

Examples of javax.measure.unit.Unit


                final double semiMajorAxis     = getDouble(result, 3, code);
                final double inverseFlattening = result.getDouble( 4);
                final double semiMinorAxis     = result.getDouble( 5);
                final String unitCode          = getString(result, 6, code);
                final String remarks           = result.getString( 7);
                final Unit   unit              = createUnit(unitCode);
                final Map<String,Object> properties = generateProperties(name, epsg, remarks);
                final Ellipsoid ellipsoid;
                if (inverseFlattening == 0) {
                    if (semiMinorAxis == 0) {
                        // Both are null, which is not allowed.
View Full Code Here


                final String epsg      = getString(result, 1, code);
                final String name      = getString(result, 2, code);
                final double longitude = getDouble(result, 3, code);
                final String unit_code = getString(result, 4, code);
                final String remarks   = result.getString( 5);
                final Unit unit        = createUnit(unit_code);
                final Map<String,Object> properties = generateProperties(name, epsg, remarks);
                PrimeMeridian primeMeridian = factories.getDatumFactory().createPrimeMeridian(
                                              properties, longitude, unit);
                returnValue = ensureSingleton(primeMeridian, returnValue, code);
            }
View Full Code Here

            ResultSet result = stmt.executeQuery();
            while (result.next()) {
                final String epsg    = getString(result, 1, code);
                final String name    = getString(result, 2, code);
                final String remarks = result.getString( 3);
                final Unit   unit;
                final Class  type;
                /*
                 * Search for units. We will choose the most commonly used one in parameter values.
                 * If the parameter appears to have at least one non-null value in the "Parameter
                 * File Name" column, then the type is assumed to be URI. Otherwise, the type is a
View Full Code Here

        stmt.setString(2, operation);
        final ResultSet result = stmt.executeQuery();
        while (result.next()) {
            final String name  = getString(result, 1, operation);
            final double value = result.getDouble( 2);
            final Unit   unit;
            Object reference;
            if (result.wasNull()) {
                /*
                 * If no numeric values were provided in the database, then the values must
                 * appears in some external file. It may be a file to download from FTP.
View Full Code Here

                     * the case of Molodenski transforms, the axis length to set are the same.
                     */
                    if (isBursaWolf) try {
                        Ellipsoid ellipsoid = CRSUtilities.getHeadGeoEllipsoid(sourceCRS);
                        if (ellipsoid != null) {
                            final Unit axisUnit = ellipsoid.getAxisUnit();
                            parameters.parameter("src_semi_major").setValue(ellipsoid.getSemiMajorAxis(), axisUnit);
                            parameters.parameter("src_semi_minor").setValue(ellipsoid.getSemiMinorAxis(), axisUnit);
                            parameters.parameter("src_dim").setValue(sourceCRS.getCoordinateSystem().getDimension());
                        }
                        ellipsoid = CRSUtilities.getHeadGeoEllipsoid(targetCRS);
                        if (ellipsoid != null) {
                            final Unit axisUnit = ellipsoid.getAxisUnit();
                            parameters.parameter("tgt_semi_major").setValue(ellipsoid.getSemiMajorAxis(), axisUnit);
                            parameters.parameter("tgt_semi_minor").setValue(ellipsoid.getSemiMinorAxis(), axisUnit);
                            parameters.parameter("tgt_dim").setValue(targetCRS.getCoordinateSystem().getDimension());
                        }
                    } catch (ParameterNotFoundException exception) {
View Full Code Here

    @Test
    public void testParsing() throws DataSourceException {

        // Test basic units parsing
        Unit unit = Utilities.parseUnit("m");
        assertEquals(unit, SI.METER);

        unit = Utilities.parseUnit("s");
        assertEquals(unit, SI.SECOND);
View Full Code Here

    //
    // getting the linear unit used by this coordinate reference system
    // since we will use it anyway.
    //
    // //
    Unit linearUnit;
    try {
      linearUnit = createUnit(GeoTiffPCSCodes.ProjLinearUnitsGeoKey,
          GeoTiffPCSCodes.ProjLinearUnitSizeGeoKey, SI.METER,
          SI.METER, metadata);
    } catch (GeoTiffException e) {
      linearUnit = null;
    }
    // //
    //
    // if it's user defined, there's a lot of work to do, we have to parse
    // many information.
    //
    // //
    if (tempCode.equalsIgnoreCase("unnamed")
        || tempCode.equals(GeoTiffConstants.GTUserDefinedGeoKey_String)) {
      return createUserDefinedPCS(metadata, linearUnit);

    }
    // //
    //
    // if it's not user defined, just use the EPSG factory to create the
    // coordinate system
    //
    // //
    try {
      if (!tempCode.startsWith("EPSG") && !tempCode.startsWith("epsg")) {
        projCode.insert(0, "EPSG:");
      }
      // it is an EPSG crs let's create it.
      final ProjectedCRS pcrs = (ProjectedCRS) CRS.decode(projCode
          .toString(), true);
      // //
      //
      // We have nothing to do with the unit of measure
      //
      // //
      if (linearUnit == null
          || linearUnit.equals(pcrs.getCoordinateSystem().getAxis(0)
              .getUnit()))
        return pcrs;
      // //
      //
      // Creating anew projected CRS
View Full Code Here

    //
    // ////////////////////////////////////////////////////////////////////
    final String tempCode = metadata
        .getGeoKey(GeoTiffGCSCodes.GeographicTypeGeoKey);
    // lookup the angular units used in this geotiff image
    Unit angularUnit = null;
    try {
      angularUnit = createUnit(GeoTiffGCSCodes.GeogAngularUnitsGeoKey,
          GeoTiffGCSCodes.GeogAngularUnitSizeGeoKey, SI.RADIAN,
          NonSI.DEGREE_ANGLE, metadata);
    } catch (GeoTiffException e) {
      angularUnit = null;
    }
    // linear unit
    Unit linearUnit = null;
    try {
      linearUnit = createUnit(GeoTiffGCSCodes.GeogLinearUnitsGeoKey,
          GeoTiffGCSCodes.GeogLinearUnitSizeGeoKey, SI.METER,
          SI.METER, metadata);
    } catch (GeoTiffException e) {
View Full Code Here

   */
  private void parseLinearUnit(final ProjectedCRS projectedCRS,
      GeoTiffIIOMetadataEncoder metadata) {

    // getting the linear unit
    final Unit linearUnit = CRSUtilities.getUnit(projectedCRS
        .getCoordinateSystem());
    if (linearUnit != null && !SI.METER.isCompatible(linearUnit)) {
      throw new IllegalArgumentException(Errors.format(
          ErrorKeys.NON_LINEAR_UNIT_$1, linearUnit));
    }
    if (SI.METER.isCompatible(linearUnit)) {
      if (SI.METER.equals(linearUnit)) {
        metadata.addGeoShortParam(
            GeoTiffPCSCodes.ProjLinearUnitsGeoKey,
            GeoTiffUoMCodes.Linear_Meter);
        metadata.addGeoDoubleParam(
            GeoTiffPCSCodes.ProjLinearUnitSizeGeoKey, 1.0);
      }
      if (NonSI.NAUTICAL_MILE.equals(linearUnit)) {
        metadata.addGeoShortParam(
            GeoTiffPCSCodes.ProjLinearUnitsGeoKey,
            GeoTiffUoMCodes.Linear_Mile_International_Nautical);
        metadata.addGeoDoubleParam(
            GeoTiffPCSCodes.ProjLinearUnitSizeGeoKey, linearUnit
                .getConverterTo(SI.METER).convert(1));
      }
      if (NonSI.FOOT.equals(linearUnit)) {
        metadata.addGeoShortParam(
            GeoTiffPCSCodes.ProjLinearUnitsGeoKey,
            GeoTiffUoMCodes.Linear_Foot);
        metadata.addGeoDoubleParam(
            GeoTiffPCSCodes.ProjLinearUnitSizeGeoKey, linearUnit
                .getConverterTo(SI.METER).convert(1));
      }
      if (NonSI.YARD.equals(linearUnit)) {
        metadata.addGeoShortParam(
            GeoTiffPCSCodes.ProjLinearUnitsGeoKey,
            GeoTiffUoMCodes.Linear_Yard_Sears);// ??
        metadata.addGeoDoubleParam(
            GeoTiffPCSCodes.ProjLinearUnitSizeGeoKey, linearUnit
                .getConverterTo(SI.METER).convert(1));
      }
    }
  }
View Full Code Here

    final DefaultGeodeticDatum datum = (DefaultGeodeticDatum) geographicCRS
        .getDatum();
    parseDatum(datum, metadata);

    // angular unit
    final Unit angularUnit = ((EllipsoidalCS) geographicCRS
        .getCoordinateSystem()).getAxis(0).getUnit();
    parseUnit(angularUnit, 0, metadata);

    // prime meridian
    parsePrimem((DefaultPrimeMeridian) datum.getPrimeMeridian(), metadata);
View Full Code Here

TOP

Related Classes of javax.measure.unit.Unit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.