chore: add build artifacts, map assets, and routing data
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
class PlaceModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final String category;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final double elevationMeters; // GPS Altitude AMSL in meters (defaults to 0.0)
|
||||
final double? distanceKm;
|
||||
final String? address;
|
||||
|
||||
PlaceModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
this.elevationMeters = 0.0,
|
||||
this.distanceKm,
|
||||
this.address,
|
||||
});
|
||||
|
||||
factory PlaceModel.fromJson(Map<String, dynamic> json) {
|
||||
final rawElev = json['elevation_meters'] ?? json['elevation'] ?? json['altitude'] ?? 0.0;
|
||||
double elev = 0.0;
|
||||
if (rawElev is num) {
|
||||
elev = rawElev.toDouble();
|
||||
} else if (rawElev != null) {
|
||||
elev = double.tryParse(rawElev.toString()) ?? 0.0;
|
||||
}
|
||||
|
||||
return PlaceModel(
|
||||
id: json['id']?.toString() ?? '',
|
||||
name: json['name']?.toString() ?? '',
|
||||
category: json['category']?.toString() ?? 'other',
|
||||
latitude: double.tryParse(json['latitude']?.toString() ?? json['lat']?.toString() ?? '0') ?? 0.0,
|
||||
longitude: double.tryParse(json['longitude']?.toString() ?? json['lng']?.toString() ?? '0') ?? 0.0,
|
||||
elevationMeters: elev,
|
||||
distanceKm: json['distanceKm'] != null
|
||||
? (json['distanceKm'] as num).toDouble()
|
||||
: null,
|
||||
address: json['address']?.toString() ?? json['neighborhood']?.toString(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'category': category,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'elevation_meters': elevationMeters,
|
||||
'altitude': elevationMeters,
|
||||
if (address != null) 'address': address,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user