common library
Common codes, constants, functions, presentation helpers and reference systems related to geospatial applications.
Features:
- Enums (codes): geospatial coordinate, geometry types, dimensionality, canvas origin, cardinal direction, DMS type, geo representation, axis order, hemisphere, coordinate reference system types.
- Constants: epsilon, geodetic and screen related constants.
- Conversions: angle, angular velocity, area, distance, speed and time.
- Functions: conversions between units, geographic coordinate helpers.
- Presentation: DMS (degree-minutes-seconds geographic representations).
- Reference: Coordinate and temporal reference systems. Reference ellipsoids.
This libary exports a subset of package:geobase/geobase.dart
.
Usage: import package:geobase/common.dart
Examples on unit conversions:
// Length units (mm, cm, m, km, in, ft, yd, mi, nmi), with some examples:
const meters = 1500.0;
meters.convertLength(to: LengthUnit.foot); // ~ 4921.26 ft
meters.convertLength(to: LengthUnit.kilometer); // 1.5 km
meters.convertLength(to: LengthUnit.nauticalMile); // 0.8099 nmi
254.convertLength(from: LengthUnit.millimeter, to: LengthUnit.inch); // 10.0
// Area units (mm², cm², m², km², in², ft², yd², mi², ac, ha), with examples:
const squareMeters = 10000.0;
squareMeters.convertArea(to: AreaUnit.squareKilometer); // 0.01 km²
squareMeters.convertArea(to: AreaUnit.acre); // ~ 2.4711 acres
1.0.convertArea(
from: AreaUnit.hectare,
to: AreaUnit.squareFoot,
); // 107639.1042 ft²
// Speed units (mm/s, cm/s, m/s, km/h, mph, ft/s, kn), with some examples:
const metersPerSecond = 10.0;
metersPerSecond.convertSpeed(to: SpeedUnit.kilometerPerHour); // 36.0 km/h
metersPerSecond.convertSpeed(to: SpeedUnit.milePerHour); // 22.3694 mph
10.0.convertSpeed(
from: SpeedUnit.kilometerPerHour,
to: SpeedUnit.knot,
); // ~ 5.3996 kn
// Angle units (mrad, rad, arcsec, arcmin, deg, gon, turn), with examples:
const degrees = 90.0;
degrees.convertAngle(from: AngleUnit.degree); // ~1.5708 rad
degrees.convertAngle(from: AngleUnit.degree, to: AngleUnit.gradian); // 100.0
// Angular velocity units (mrad/s, rad/s, deg/s, rpm, rps), with examples:
const radiansPerSecond = 1.0;
radiansPerSecond.convertAngularVelocity(
to: AngularVelocityUnit.degreePerSecond,
); // ~ 57.296 deg/s
720.0.convertAngularVelocity(
from: AngularVelocityUnit.degreePerSecond,
to: AngularVelocityUnit.revolutionPerSecond,
); // 2.0 rps
// Time units (ns, µs, ms, s, min, h, d, w), with some examples:
const seconds = 3600.0;
seconds.convertTime(to: TimeUnit.hour); // 1.0 h
seconds.convertTime(to: TimeUnit.day); // 0.0417 d
1.0.convertTime(from: TimeUnit.week, to: TimeUnit.day); // 7.0 d
Classes
- CoordRefSys
- Metadata about a coordinate reference system (CRS) identified and specified by id.
- CoordRefSysResolver
- An abstract class for resolving coordinate reference system information.
- Dms
- A default implementation for DmsFormat abstract base class, that defines methods for parsing and formatting degrees/minutes/seconds on latitude, longitude and bearing values.
- DmsFormat
- A base class for formatters with methods for parsing and formatting degrees/minutes/seconds on latitude, longitude and bearing values.
- Ellipsoid
- A reference ellipsoid with ellipsoidal parameters (a, b and f).
- TemporalRefSys
- Metadata about a temporal coordinate reference system (TRS) identified and specified by id.
- TemporalRefSysResolver
- An abstract class for resolving temporal coordinate reference system information.
Enums
- AngleUnit
- An enumeration of angle units.
- AngularVelocityUnit
- An enumeration of angular velocity units.
- AreaUnit
- An enumeration of area units.
- AxisOrder
- The axis order of coordinate values in position and point representations.
- CanvasOrigin
- The position of the origin in a canvas or a grid.
- CardinalPrecision
- The precision for cardinal directions (compass point).
- CoordRefSysType
- An enumeration of common coordinate reference system (CRS) types.
- Coords
- An enum for coordinate types (by spatial dimension and whether is measured).
- Dimensionality
- An enum for dimensionality or topological dimension in the context of geospatial applications.
- DmsType
- An enum for common representation of geographic positions by coordinates (using degrees, minutes and seconds as components).
- Geom
- An enum for geometry types.
- GeoRepresentation
- An enum for spatial representations that can be used to code logic when need to choose some options based on a representation.
- Hemisphere
- An enum representing the hemispheres of the Earth.
- LengthUnit
- An enumeration of length (distance) units.
- SpeedUnit
- An enumeration of speed units.
- TimeUnit
- An enumeration of time units (representing values of time duration or intervals).
Extensions
- DoubleAngleExtension on double
- An extension on double with basic degrees and radians utility methods.
- GeographicDoubleAngleExtension on double
- An extension on double with basic degrees and radians utility methods ( (for geographic coordinate reference systems).
- UnitConversionExtension on num
- An extension on double with conversion methods for angle, angular velocity, area, length, speed and time units.
Constants
- defaultEpsilon → const double
-
The default epsilon value
1.0e-9
used as a tolerance inequals2D
,equals3D
and similar methods in this package. - doublePrecisionEpsilon → const double
- The maximum relative precision of double numbers (IEEE 754).
- earthCircumferenceWgs84 → const double
- The earth circumference in meters (from earth equatorial radius by WGS 84).
- earthRadiusWgs84 → const double
- The earth equatorial radius in meters as specified by WGS 84.
- maxLatitude → const double
- The maximum value for the geographic latitude.
- maxLatitudeUTM → const double
- The maximum value for the geographic latitude inside the Universal Transverse Mercator (UTM) projection coverage.
- maxLatitudeWebMercator → const double
- The maximum value for the geographic latitude inside the Web Mercator projection coverage.
- maxLongitude → const double
- The maximum value for the geographic longitude.
- minLatitude → const double
- The minimum value for the geographic latitude.
- minLatitudeUTM → const double
- The minimum value for the geographic latitude inside the Universal Transverse Mercator (UTM) projection coverage.
- minLatitudeWebMercator → const double
- The minimum value for the geographic latitude inside the Web Mercator projection coverage.
- minLongitude → const double
- The minimum value for the geographic longitude.
- screenPPIbyOGC → const double
- OGC defines a screen pixel of 0.28 mm that approximates to 90.7 ppi.