You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@sis.apache.org by Michael Arneson <mi...@geotoolkit.net> on 2024/03/22 17:18:20 UTC
Replacement for DefaultFactories in Apache SIS 1.4
I was using the following code to in Apache 1.3 to convert a geog2D
transformation to a geog3D transformation.
CoordinateOperation operation = ...
ParameterValueGroup srcp = ((SingleOperation)
operation).getParameterValues();
String oldName = ((SingleOperation)
operation).getMethod().getName().getCode();
String newName = oldName.replace("geog2D", "geog3D");
MathTransformFactory mtFactory =
DefaultFactories.forClass(MathTransformFactory.class);
ParameterValueGroup tgtp = mtFactory.getDefaultParameters(newName);
Ellipsoid sourceEllipsoid = ((GeographicCRS)
operation.getSourceCRS()).getDatum().getEllipsoid();
Ellipsoid targetEllipsoid = ((GeographicCRS)
operation.getTargetCRS()).getDatum().getEllipsoid();
tgtp.parameter("src_semi_major").setValue(sourceEllipsoid.getSemiMajorAxis(),
sourceEllipsoid.getAxisUnit());
tgtp.parameter("src_semi_minor").setValue(sourceEllipsoid.getSemiMinorAxis(),
sourceEllipsoid.getAxisUnit());
tgtp.parameter("tgt_semi_major").setValue(targetEllipsoid.getSemiMajorAxis(),
targetEllipsoid.getAxisUnit());
tgtp.parameter("tgt_semi_minor").setValue(targetEllipsoid.getSemiMinorAxis(),
targetEllipsoid.getAxisUnit());
...
Since DefaultFactories has been removed in Apache SIS 1.4, what would be
the best way to modify this code to work with Apache SIS 1.4?
Thanks,
--
*Michael Arneson*
*Software Engineer*
*Office:* +1 (713) 975-7434
michael.arneson@int.com
*INT *| *Empowering Visualization*
Re: Replacement for DefaultFactories in Apache SIS 1.4
Posted by Martin Desruisseaux <ma...@geomatys.com>.
Hello Michael
Le 2024-03-22 à 18 h 18, Michael Arneson a écrit :
> I was using the following code to in Apache 1.3 to convert a geog2D
> transformation to a geog3D transformation.
>
> (…snip…)
> MathTransformFactory mtFactory =
> DefaultFactories.forClass(MathTransformFactory.class);
> (…snip…)
>
> Since DefaultFactories has been removed in Apache SIS 1.4, what would
> be the best way to modify this code to work with Apache SIS 1.4?
It can be done as below:
MathTransformFactory mtFactory = DefaultMathTransformFactory.provider();
The "provider" method name is mandated by the Java Module System (a.k.a.
"Jigsaw"). The replacement of the `DefaultFactories` class by
`provider()` static methods was part of the SIS modularization work.
Note that `DefaultFactories` was an internal class, while those new
`provider()` methods are in public API, so they are not expected to change.
Martin
P.S.: the work for upgrading to ISO 19111:2019 is in progress right now.
First on GeoAPI, SIS will follow next. If you are curious, the work can
be seen at [1]. Once completed, SIS will be able (at last) to upgrade to
latest EPSG dataset versions.
[1]https://github.com/opengeospatial/geoapi/commits/master/