conversion = new DefaultConversion(properties, method, null, parameters); } catch (IllegalArgumentException exception) { throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
conversion = new DefaultConversion(properties, method, null, parameters); } catch (IllegalArgumentException exception) { throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
/** * For {@link DefaultDerivedCRS#DefaultDerivedCRS(Map, SingleCRS, CoordinateReferenceSystem, OperationMethod, * MathTransform, CoordinateSystem)} constructor only (<strong>not legal for {@code ProjectedCRS}</strong>). */ @SuppressWarnings("unchecked") AbstractDerivedCRS(final Map<String,?> properties, final SingleCRS baseCRS, final CoordinateReferenceSystem interpolationCRS, final OperationMethod method, final MathTransform baseToDerived, final CoordinateSystem derivedCS) throws MismatchedDimensionException { super(properties, derivedCS); ArgumentChecks.ensureNonNull("baseCRS", baseCRS); ArgumentChecks.ensureNonNull("method", method); ArgumentChecks.ensureNonNull("baseToDerived", baseToDerived); conversionFromBase = (C) new DefaultConversion( // Cast to (C) is valid only for DefaultDerivedCRS. ConversionKeys.unprefix(properties), baseCRS, this, interpolationCRS, method, baseToDerived); }
conversion = new DefaultProjection(definition, sourceCRS, targetCRS, factory, actual); } else { conversion = new DefaultConversion(definition, sourceCRS, targetCRS, factory, actual);
/** * For {@link DefaultDerivedCRS#DefaultDerivedCRS(Map, SingleCRS, CoordinateReferenceSystem, OperationMethod, * MathTransform, CoordinateSystem)} constructor only (<strong>not legal for {@code ProjectedCRS}</strong>). */ @SuppressWarnings("unchecked") AbstractDerivedCRS(final Map<String,?> properties, final SingleCRS baseCRS, final CoordinateReferenceSystem interpolationCRS, final OperationMethod method, final MathTransform baseToDerived, final CoordinateSystem derivedCS) throws MismatchedDimensionException { super(properties, derivedCS); ArgumentChecks.ensureNonNull("baseCRS", baseCRS); ArgumentChecks.ensureNonNull("method", method); ArgumentChecks.ensureNonNull("baseToDerived", baseToDerived); conversionFromBase = (C) new DefaultConversion( // Cast to (C) is valid only for DefaultDerivedCRS. ConversionKeys.unprefix(properties), baseCRS, this, interpolationCRS, method, baseToDerived); }
conversion = new DefaultProjection(definition, sourceCRS, targetCRS, factory, actual); } else { conversion = new DefaultConversion(definition, sourceCRS, targetCRS, factory, actual);
/** * Returns a SIS implementation for the given conversion. * * @see DefaultConversion#castOrCopy(Conversion) */ static DefaultConversion forConversion(final Conversion object) { if (object instanceof CylindricalProjection) { return (object instanceof DefaultCylindricalProjection) ? ((DefaultCylindricalProjection) object) : new DefaultCylindricalProjection((CylindricalProjection) object); } if (object instanceof ConicProjection) { return (object instanceof DefaultConicProjection) ? ((DefaultConicProjection) object) : new DefaultConicProjection((ConicProjection) object); } if (object instanceof PlanarProjection) { return (object instanceof DefaultPlanarProjection) ? ((DefaultPlanarProjection) object) : new DefaultPlanarProjection((PlanarProjection) object); } if (object instanceof Projection) { return (object instanceof DefaultProjection) ? ((DefaultProjection) object) : new DefaultProjection((Projection) object); } if (object == null || object instanceof DefaultConversion) { return (DefaultConversion) object; } return new DefaultConversion(object); }
/** * Returns a SIS implementation for the given conversion. * * @see DefaultConversion#castOrCopy(Conversion) */ static DefaultConversion forConversion(final Conversion object) { if (object instanceof CylindricalProjection) { return (object instanceof DefaultCylindricalProjection) ? ((DefaultCylindricalProjection) object) : new DefaultCylindricalProjection((CylindricalProjection) object); } if (object instanceof ConicProjection) { return (object instanceof DefaultConicProjection) ? ((DefaultConicProjection) object) : new DefaultConicProjection((ConicProjection) object); } if (object instanceof PlanarProjection) { return (object instanceof DefaultPlanarProjection) ? ((DefaultPlanarProjection) object) : new DefaultPlanarProjection((PlanarProjection) object); } if (object instanceof Projection) { return (object instanceof DefaultProjection) ? ((DefaultProjection) object) : new DefaultProjection((Projection) object); } if (object == null || object instanceof DefaultConversion) { return (DefaultConversion) object; } return new DefaultConversion(object); }
/** * Creates a Universal Transverse Mercator (UTM) or a Universal Polar Stereographic (UPS) projected CRS * using the Apache SIS factory implementation. This method restricts the factory to SIS implementation * instead than arbitrary factory in order to meet the contract saying that {@link CommonCRS} methods * should never fail. * * @param code the EPSG code, or 0 if none. * @param baseCRS the geographic CRS on which the projected CRS is based. * @param isUTM {@code true} for UTM or {@code false} for UPS. Note: redundant with the given latitude. * @param latitude a latitude in the zone of the desired projection, to be snapped to 0°, 90°S or 90°N. * @param longitude a longitude in the zone of the desired projection, to be snapped to UTM central meridian. * @param derivedCS the projected coordinate system. */ static ProjectedCRS createUniversal(final int code, final GeographicCRS baseCRS, final boolean isUTM, final double latitude, final double longitude, final CartesianCS derivedCS) { final OperationMethod method; try { method = DefaultFactories.forBuildin(MathTransformFactory.class, DefaultMathTransformFactory.class) .getOperationMethod(isUTM ? TransverseMercator.NAME : PolarStereographicA.NAME); } catch (NoSuchIdentifierException e) { throw new IllegalStateException(e); // Should not happen with SIS implementation. } final ParameterValueGroup parameters = method.getParameters().createValue(); String name = isUTM ? TransverseMercator.Zoner.UTM.setParameters(parameters, latitude, longitude) : PolarStereographicA.setParameters(parameters, latitude >= 0); final DefaultConversion conversion = new DefaultConversion(properties(0, name, null, false), method, null, parameters); name = baseCRS.getName().getCode() + " / " + name; return new DefaultProjectedCRS(properties(code, name, null, false), baseCRS, conversion, derivedCS); }
op = new DefaultConversion(properties, sourceCRS, targetCRS, interpolationCRS, method, transform); } else { // See above comment about this last-resort fallback. op = new AbstractSingleOperation(properties, sourceCRS, targetCRS, interpolationCRS, method, transform);
/** * Creates a Universal Transverse Mercator (UTM) or a Universal Polar Stereographic (UPS) projected CRS * using the Apache SIS factory implementation. This method restricts the factory to SIS implementation * instead than arbitrary factory in order to met the contract saying that {@link CommonCRS} methods * should never fail. * * @param code the EPSG code, or 0 if none. * @param baseCRS the geographic CRS on which the projected CRS is based. * @param isUTM {@code true} for UTM or {@code false} for UPS. Note: redundant with the given latitude. * @param latitude a latitude in the zone of the desired projection, to be snapped to 0°, 90°S or 90°N. * @param longitude a longitude in the zone of the desired projection, to be snapped to UTM central meridian. * @param derivedCS the projected coordinate system. */ static ProjectedCRS createUniversal(final int code, final GeographicCRS baseCRS, final boolean isUTM, final double latitude, final double longitude, final CartesianCS derivedCS) { final OperationMethod method; try { method = DefaultFactories.forBuildin(MathTransformFactory.class, DefaultMathTransformFactory.class) .getOperationMethod(isUTM ? TransverseMercator.NAME : PolarStereographicA.NAME); } catch (NoSuchIdentifierException e) { throw new IllegalStateException(e); // Should not happen with SIS implementation. } final ParameterValueGroup parameters = method.getParameters().createValue(); String name = isUTM ? TransverseMercator.Zoner.UTM.setParameters(parameters, latitude, longitude) : PolarStereographicA.setParameters(parameters, latitude >= 0); final DefaultConversion conversion = new DefaultConversion(properties(0, name, null, false), method, null, parameters); name = baseCRS.getName().getCode() + " / " + name; return new DefaultProjectedCRS(properties(code, name, null, false), baseCRS, conversion, derivedCS); }
/** * Creates a “Tokyo to JGD2000” transformation. * * @see DefaultTransformationTest#createGeocentricTranslation() */ private static DefaultConcatenatedOperation createGeocentricTranslation() throws FactoryException, NoninvertibleTransformException { final MathTransformFactory mtFactory = DefaultFactories.forBuildin(MathTransformFactory.class); final DefaultTransformation op = DefaultTransformationTest.createGeocentricTranslation(); final DefaultConversion before = new DefaultConversion( Collections.singletonMap(DefaultConversion.NAME_KEY, "Geographic to geocentric"), HardCodedCRS.TOKYO, // SourceCRS op.getSourceCRS(), // TargetCRS null, // InterpolationCRS DefaultOperationMethodTest.create("Geographic/geocentric conversions", "9602", "EPSG guidance note #7-2", 3), EllipsoidToCentricTransform.createGeodeticConversion(mtFactory, HardCodedDatum.TOKYO.getEllipsoid(), true)); final DefaultConversion after = new DefaultConversion( Collections.singletonMap(DefaultConversion.NAME_KEY, "Geocentric to geographic"), op.getTargetCRS(), // SourceCRS HardCodedCRS.JGD2000, // TargetCRS null, // InterpolationCRS DefaultOperationMethodTest.create("Geographic/geocentric conversions", "9602", "EPSG guidance note #7-2", 3), EllipsoidToCentricTransform.createGeodeticConversion(mtFactory, HardCodedDatum.JGD2000.getEllipsoid(), true).inverse()); return new DefaultConcatenatedOperation( Collections.singletonMap(DefaultConversion.NAME_KEY, "Tokyo to JGD2000"), new AbstractSingleOperation[] {before, op, after}, mtFactory); }
/** * Returns the inverse of the given conversion. This method is not strictly correct * since we reuse the properties (name, aliases, etc.) from the given conversion. * However those properties are not significant for the purpose of this test. */ private static Conversion inverse(final Conversion conversion) throws NoninvertibleTransformException { return new DefaultConversion(IdentifiedObjects.getProperties(conversion), conversion.getTargetCRS(), conversion.getSourceCRS(), null, conversion.getMethod(), conversion.getMathTransform().inverse()); }
final Conversion fromBase = new DefaultConversion(name, method, tr, parameters); return crsFactory.createProjectedCRS(name, (GeographicCRS) baseCRS, fromBase, withHeight ? csFactory.createCartesianCS(csName, axes[0], axes[1], axes[2]) :
final Conversion fromBase = new DefaultConversion(name, method, tr, parameters); return crsFactory.createProjectedCRS(name, (GeographicCRS) baseCRS, fromBase, withHeight ? csFactory.createCartesianCS(csName, axes[0], axes[1], axes[2]) :
mtFactory.createAffineTransform(append)); mt = mtFactory.createPassThroughTransform(0, mt, 1); projection = new DefaultConversion(IdentifiedObjects.getProperties(projection), projection.getMethod(), mt, null); return crsFactory.createProjectedCRS(crsName, base3D, projection, targetCS);
final GeographicCRS base = (GeographicCRS) getHorizontalComponent(proj.getBaseCRS()); Conversion fromBase = proj.getConversionFromBase(); fromBase = new DefaultConversion(IdentifiedObjects.getProperties(fromBase), fromBase.getMethod(), null, fromBase.getParameterValues()); return new DefaultProjectedCRS(properties, base, fromBase, (CartesianCS) cs);
final GeographicCRS base = (GeographicCRS) getHorizontalComponent(proj.getBaseCRS()); Conversion fromBase = proj.getConversionFromBase(); fromBase = new DefaultConversion(IdentifiedObjects.getProperties(fromBase), fromBase.getMethod(), null, fromBase.getParameterValues()); return new DefaultProjectedCRS(properties, base, fromBase, (CartesianCS) cs);
public void testDefiningConversion() throws FactoryException { final DefaultConversion reference = createLongitudeRotation(true); final DefaultConversion definingConversion = new DefaultConversion( IdentifiedObjects.getProperties(reference), reference.getMethod(),
new DefaultConversion(dummyName, method, mt, null), HardCodedCS.PROJECTED); final Conversion projection = crs.getConversionFromBase();