Location class

Represents a geographical location with latitude and longitude coordinates.

This model is used to store precise location data for mosquito observations, supporting both the submission of new observations and the retrieval of existing observation data from external sources.

Usage Example

// Create a location for New York City
final location = Location(lat: 40.7128, lng: -74.0060);

// Serialize to JSON for API transmission
final json = location.toJson();
// {'lat': 40.7128, 'lng': -74.0060}

// Deserialize from JSON
final locationFromJson = Location.fromJson(json);

Coordinate System

Uses the WGS84 coordinate system (EPSG:4326) which is standard for GPS and web mapping applications. Coordinates are in decimal degrees.

Validation

  • Latitude must be between -90.0 and 90.0 degrees
  • Longitude must be between -180.0 and 180.0 degrees

See also:

  • Observation which uses this model for location data
  • Flutter's geolocator package for obtaining device location

Constructors

Location({required double lat, required double lng})
Creates a new Location instance.
Location.fromJson(Map<String, dynamic> json)
Creates a Location from a JSON map.
factory

Properties

hashCode int
Returns the hash code for this location.
no setteroverride
lat double
Latitude coordinate in decimal degrees.
final
lng double
Longitude coordinate in decimal degrees.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts this Location to a JSON map.
toString() String
Returns a string representation of this location.
override

Operators

operator ==(Object other) bool
Checks if two Location instances are equal.
override