tryInit static method
Proj4d?
tryInit(
- CoordRefSys sourceCrs,
- CoordRefSys targetCrs, {
- String? sourceDef,
- String? targetDef,
Initializes a projection adapter between sourceCrs
and
targetCrs
.
As based on the Proj4dart package, it has built-in support for following identifiers: "EPSG:4326" (with alias "WGS84"), "EPSG:4269", "EPSG:3857" (with aliases "EPSG:3785", "GOOGLE", "EPSG:900913", "EPSG:102113").
All CoordRefSys instances with epsg
property among those identifiers,
CoordRefSys.CRS84
and CoordRefSys.CRS84h
also resolves to those
supported coordinates reference systems.
For all other coordinate reference systems, also a projection definition
must be given via sourceDef
or targetDef
. Proj4 definition strings,
OGC WKT definitions and ESRI WKT definitions are supported. More info from
the Proj4dart package.
Returns null if projections could not be initialized.
Implementation
static Proj4d? tryInit(
CoordRefSys sourceCrs,
CoordRefSys targetCrs, {
String? sourceDef,
String? targetDef,
}) {
try {
return Proj4d.init(
sourceCrs,
targetCrs,
sourceDef: sourceDef,
targetDef: targetDef,
);
} on Exception {
return null;
}
}