Proj4d.init constructor

Proj4d.init(
  1. CoordRefSys sourceCrs,
  2. CoordRefSys targetCrs, {
  3. String? sourceDef,
  4. 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.

Throws FormatException if projections could not be initialized.

Implementation

factory Proj4d.init(
  CoordRefSys sourceCrs,
  CoordRefSys targetCrs, {
  String? sourceDef,
  String? targetDef,
}) =>
    Proj4d(
      sourceCrs,
      targetCrs,
      p4d.ProjectionTuple(
        fromProj: _resolveProj4dProjection(sourceCrs, sourceDef),
        toProj: _resolveProj4dProjection(targetCrs, targetDef),
      ),
    );