Proj4Crs.fromFactory constructor
Proj4Crs.fromFactory({})
Implementation
factory Proj4Crs.fromFactory({
required String code,
required pj4.Projection pj4Projection,
Transformation? transformation,
List<UPoint>? origins,
Bounds? bounds,
List<double>? scales,
List<double>? resolutions,
}) {
Projection projection = Pj4Projection(
pj4Projection: pj4Projection,
bounds: bounds,
latBounds: const Tuple2(-90.0, 90.0),
lngBounds: const Tuple2(-180.0, 180.0),
);
List<Transformation>? transformations;
bool infinite = null == bounds;
List<double> finalScales;
if (scales != null && scales.isNotEmpty) {
finalScales = scales;
} else if (resolutions != null && resolutions.isNotEmpty) {
finalScales = resolutions.map((r) => 1 / r).toList(growable: false);
} else {
throw Exception(
'You should provide scales or resolutions to calculate scales');
}
if (origins == null || origins.isEmpty) {
transformation ??= const Transformation(1, 0, -1, 0);
} else {
if (origins.length == 1) {
var origin = origins[0];
transformation = Transformation(1, -origin.x, -1, origin.y);
} else {
transformations =
origins.map((p) => Transformation(1, -p.x, -1, p.y)).toList();
transformation = null;
}
}
return Proj4Crs._(
code: code,
projection: projection,
transformation: transformation!,
infinite: infinite,
transformations: transformations,
scales: finalScales,
);
}