/** * Returns the parameter value for the specified operation parameter. Values are automatically * converted into the standard units specified by the supplied {@code param} argument. This * convenience method is used by subclasses for initializing {@linkplain MathTransform math * transform} from a set of parameters. * * @param param The parameter to look for. * @param group The parameter value group to search into. * @return The requested parameter value, or {@code NaN} if {@code param} is {@linkplain * #createOptionalDescriptor optional} and the user didn't provided any value. * @throws ParameterNotFoundException if the parameter is not found. * @todo Move to the {@link org.geotools.parameter.Parameters} class. */ protected static double doubleValue( final ParameterDescriptor<?> param, final ParameterValueGroup group) throws ParameterNotFoundException { final Unit<?> unit = param.getUnit(); final ParameterValue<?> value = getParameter(param, group); return (value == null) ? Double.NaN : (unit != null) ? value.doubleValue(unit) : value.doubleValue(); }
/** * Creates a transform from the specified group of parameter values. * * @param parameters The group of parameter values. * @return The created math transform. * @throws ParameterNotFoundException if a required parameter was not found. */ protected MathTransform createMathTransform(final ParameterValueGroup parameters) throws ParameterNotFoundException { // switch sp1 and sp2 so that we get a consistent ordering, this allows to recognize // t Lambert conformal with the same standard parallels declared in opposite order ParameterValue<Double> sp1 = getParameter(STANDARD_PARALLEL_1, parameters); ParameterValue<Double> sp2 = getParameter(STANDARD_PARALLEL_2, parameters); if (sp1 != null && sp2 != null) { if (sp1.doubleValue() < sp2.doubleValue()) { final double temp = sp1.doubleValue(); sp1.setValue(sp2.doubleValue()); sp2.setValue(temp); } } return new LambertConformal2SP(parameters); } }
protected CylindricalEqualArea(final ParameterValueGroup parameters) throws ParameterNotFoundException { super(parameters); // Set trueScaleLatitude ("lat_ts" in Proj4) trueScaleLatitude = DTR * parameters.parameter("standard_parallel_1").doubleValue(); es = excentricitySquared; e = excentricity; one_es = 1 - (excentricitySquared); double t = trueScaleLatitude; scaleFactor = Math.cos(t); if (es != 0) { t = Math.sin(t); scaleFactor /= Math.sqrt(1. - es * t * t); e = Math.sqrt(es); // P->e = sqrt(P->es); apa = ProjectionMath.authset(es); qp = ProjectionMath.qsfn(1., e, one_es); } }
private static GeneralDirectPosition getProjectionCenterLonLat( CoordinateReferenceSystem crs, GeneralDirectPosition centerPt) { // set defaults centerPt.setOrdinate(0, 0); centerPt.setOrdinate(1, 0); MapProjection projection = getMapProjection(crs); if (projection == null) { return centerPt; } for (GeneralParameterValue gpv : projection.getParameterValues().values()) { // for safety if (!(gpv instanceof ParameterValue)) { continue; } ParameterValue pv = (ParameterValue) gpv; ReferenceIdentifier pvName = pv.getDescriptor().getName(); if (MapProjection.AbstractProvider.LATITUDE_OF_ORIGIN.getName().equals(pvName)) { centerPt.setOrdinate(1, pv.doubleValue()); } else if (MapProjection.AbstractProvider.LATITUDE_OF_CENTRE.getName().equals(pvName)) { centerPt.setOrdinate(1, pv.doubleValue()); } else if (MapProjection.AbstractProvider.LONGITUDE_OF_CENTRE .getName() .equals(pvName)) { centerPt.setOrdinate(0, pv.doubleValue()); } else if (MapProjection.AbstractProvider.CENTRAL_MERIDIAN.getName().equals(pvName)) { centerPt.setOrdinate(0, pv.doubleValue()); } } return centerPt; }
double value; try { value = param.doubleValue(unit); } catch (IllegalStateException exception) {
/** * Creates a matrix from this group of parameters. * * @return A matrix created from this group of parameters. */ public Matrix getMatrix() { final int numRow = this.numRow.intValue(); final int numCol = this.numCol.intValue(); final Matrix matrix = MatrixFactory.create(numRow, numCol); if (matrixValues != null) { for (int j = 0; j < numRow; j++) { final ParameterValue[] row = matrixValues[j]; if (row != null) { for (int i = 0; i < numCol; i++) { final ParameterValue element = row[i]; if (element != null) { matrix.setElement(j, i, element.doubleValue()); } } } } } return matrix; }
Integer.parseInt(name.substring(prefix.length(), split)); final int col = Integer.parseInt(name.substring(split + 1)); matrix.setElement(row, col, ((ParameterValue) param).doubleValue()); continue; } catch (NumberFormatException exception) {
.getName() .getCode()) .doubleValue(); double longitudeOfCenter = params.parameter( .getName() .getCode()) .doubleValue();
ParameterValue<Double> sp2 = getParameter(STANDARD_PARALLEL_2, parameters); if (sp1 != null && sp2 != null) { if (sp1.doubleValue() < sp2.doubleValue()) { final double temp = sp1.doubleValue(); sp1.setValue(sp2.doubleValue()); sp2.setValue(temp);
@Test public void testSpheroidalWKTParameters() { ParameterValueGroup parameters = CRS.getMapProjection(sphericalGeosCRS).getParameterValues(); double satelliteHeight = parameters.parameter("satellite_height").doubleValue(); assertThat(satelliteHeight, is(35832548.5)); }
@Test public void testEllipsoidalWKTParameters() { ParameterValueGroup parameters = CRS.getMapProjection(ellipsoidalGeosCRS).getParameterValues(); double satelliteHeight = parameters.parameter("satellite_height").doubleValue(); assertThat(satelliteHeight, is(35785831.0)); }
/** Circumscribed rectangle (smallest) for full disk earth image */ public static Envelope2D circumscribeFullDisk(CoordinateReferenceSystem geosCRS) throws TransformException, FactoryException { if (!isGeostationaryCRS(geosCRS)) { return null; } MathTransform mt = CRS.findMathTransform(geosCRS, CRS.getProjectedCRS(geosCRS).getBaseCRS(), true); MathTransform imt = mt.inverse(); ParameterValueGroup parameters = CRS.getMapProjection(geosCRS).getParameterValues(); double semiMajorAxis = parameters.parameter("semi_major").doubleValue(); double satelliteHeight = parameters.parameter("satellite_height").doubleValue(); double centralMeridian = parameters.parameter("central_meridian").doubleValue(); DirectPosition2D dp2d = new DirectPosition2D(); double halfFoVRadians = Math.acos(semiMajorAxis / (satelliteHeight + semiMajorAxis)); double halfFoVDegrees = Math.toDegrees(halfFoVRadians); dp2d.setLocation(centralMeridian - halfFoVDegrees, 0.); imt.transform(dp2d, dp2d); double xMin = dp2d.getX(); dp2d.setLocation(centralMeridian + halfFoVDegrees, 0.); imt.transform(dp2d, dp2d); double xMax = dp2d.getX(); dp2d.setLocation(centralMeridian, -halfFoVDegrees); imt.transform(dp2d, dp2d); double yMin = dp2d.getY(); dp2d.setLocation(centralMeridian, halfFoVDegrees); imt.transform(dp2d, dp2d); double yMax = dp2d.getY(); return new Envelope2D(geosCRS, xMin, yMin, xMax - xMin, yMax - yMin); }
.getParameterValues() .parameter(AbstractProvider.CENTRAL_MERIDIAN.getName().getCode()) .doubleValue();
.getParameterValues() .parameter(AbstractProvider.CENTRAL_MERIDIAN.getName().getCode()) .doubleValue(); if (wrap && maxWraps > 0) { handler =
assertEquals("semi_major", 6370997.0, param.parameter("semi_major").doubleValue(), 1E-5); assertEquals("semi_minor", 6370997.0, param.parameter("semi_minor").doubleValue(), 1E-5); assertEquals( "latitude_of_origin", 50.0, param.parameter("latitude_of_origin").doubleValue(), 1E-8); assertEquals( "central_meridian", 170.0, param.parameter("central_meridian").doubleValue(), 1E-8); assertEquals("scale_factor", 0.95, param.parameter("scale_factor").doubleValue(), 1E-8); assertEquals("false_easting", 0.0, param.parameter("false_easting").doubleValue(), 1E-8); assertEquals("false_northing", 0.0, param.parameter("false_northing").doubleValue(), 1E-8);
.getParameterValues() .parameter(centreLatCode) .doubleValue(); assertEquals(23.0, centreLat, 1e-9); .getParameterValues() .parameter(centreLongCode) .doubleValue(); assertEquals(-17.0, centreLong, 1e-9); .getParameterValues() .parameter(semiMajorString) .doubleValue(); String semiMinorString = Stereographic.Provider.SEMI_MINOR.getName().getCode(); double semiMinor = .getParameterValues() .parameter(semiMinorString) .doubleValue(); assertEquals(semiMajor, semiMinor, 1e-9);
@Test public void test97001() throws FactoryException { ProjectedCRS crs = factory.createProjectedCRS("AUTO:97001,9001,-17.0,23.0"); assertEquals("Gnomonic", crs.getConversionFromBase().getMethod().getName().getCode()); assertTrue(crs.getConversionFromBase().getMathTransform() instanceof Gnomonic); String centreLatCode = Gnomonic.Provider.LATITUDE_OF_CENTRE.getName().getCode(); double centreLat = crs.getConversionFromBase() .getParameterValues() .parameter(centreLatCode) .doubleValue(); assertEquals(23.0, centreLat, 1e-9); String centreLongCode = Gnomonic.Provider.LONGITUDE_OF_CENTRE.getName().getCode(); double centreLong = crs.getConversionFromBase() .getParameterValues() .parameter(centreLongCode) .doubleValue(); assertEquals(-17.0, centreLong, 1e-9); }
@Test public void test42004() throws FactoryException { final ProjectedCRS eqc = factory.createProjectedCRS("AUTO:42004,9001,0.0,35"); assertEquals( "Equidistant_Cylindrical", eqc.getConversionFromBase().getMethod().getName().getCode()); String stdParallel1Code = EquidistantCylindrical.Provider.STANDARD_PARALLEL_1.getName().getCode(); double stdParallel1 = eqc.getConversionFromBase() .getParameterValues() .parameter(stdParallel1Code) .doubleValue(); assertEquals(35.0, stdParallel1, 1e-9); }
"Setting 'xPeriod' on ParameterList should have no effect on ParameterValue.", 2.3, p.doubleValue(), 1E-6); assertEquals(
assertEquals("value", Double.valueOf(i), parameter.getValue()); assertEquals("unit", SI.METRE, parameter.getUnit()); assertEquals("value", i, parameter.doubleValue(SI.METRE), 0); assertEquals("value", Double.valueOf(i), parameter.getValue()); assertEquals("unit", MetricPrefix.CENTI(SI.METRE), parameter.getUnit()); assertEquals("value", i / 100, parameter.doubleValue(SI.METRE), 0);