398 lines
12 KiB
Dart
398 lines
12 KiB
Dart
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
|
import 'dart:convert';
|
|
|
|
class FeatureCollection {
|
|
final String type;
|
|
final List<Feature> features;
|
|
|
|
FeatureCollection({required this.type, required this.features});
|
|
|
|
factory FeatureCollection.fromJson(Map<String, dynamic> json) {
|
|
return FeatureCollection(
|
|
type: json['type'],
|
|
features:
|
|
List<Feature>.from(json['features'].map((x) => Feature.fromJson(x))),
|
|
);
|
|
}
|
|
}
|
|
|
|
class Feature {
|
|
final int id;
|
|
final String type;
|
|
final Geometry geometry;
|
|
final Properties properties;
|
|
|
|
Feature(
|
|
{required this.id,
|
|
required this.type,
|
|
required this.geometry,
|
|
required this.properties});
|
|
|
|
factory Feature.fromJson(Map<String, dynamic> json) {
|
|
return Feature(
|
|
id: json['id'],
|
|
type: json['type'],
|
|
geometry: Geometry.fromJson(json['geometry']),
|
|
properties: Properties.fromJson(json['properties']),
|
|
);
|
|
}
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'id': id,
|
|
'type': type,
|
|
'geometry': geometry.toMap(), // Assuming Geometry has a toMap method
|
|
'properties':
|
|
properties.toMap(), // Assuming Properties has a toMap method
|
|
};
|
|
}
|
|
|
|
Feature.fromMap(Map<String, dynamic> map)
|
|
: id = map['id'],
|
|
type = map['type'],
|
|
geometry = Geometry.fromMap(map['geometry']),
|
|
properties = Properties.fromJson(map['properties']);
|
|
|
|
static empty() {}
|
|
}
|
|
|
|
class Geometry {
|
|
final String type;
|
|
final List<List<double>> coordinates;
|
|
|
|
Geometry({required this.type, required this.coordinates});
|
|
|
|
Geometry copyWith({
|
|
String? type,
|
|
List<List<double>>? coordinates,
|
|
}) {
|
|
return Geometry(
|
|
type: type ?? this.type,
|
|
coordinates: coordinates ?? this.coordinates,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return <String, dynamic>{
|
|
'type': type,
|
|
'coordinates': coordinates,
|
|
};
|
|
}
|
|
|
|
factory Geometry.fromMap(Map<String, dynamic> map) {
|
|
return Geometry(
|
|
type: map['type'] as String,
|
|
coordinates: List<List<double>>.from(
|
|
(map['coordinates'] as List<dynamic>).map<List<double>>(
|
|
(coordinateList) {
|
|
// Ensure 'coordinateList' is treated as a List of dynamic elements.
|
|
// Then, for each element in the list, explicitly cast or convert it to double.
|
|
return List<double>.from(coordinateList.map((coordinate) {
|
|
// 'coordinate' is dynamic, needs explicit conversion to double.
|
|
// The conversion depends on the original data type of 'coordinate';
|
|
// if it's already a number, you can use .toDouble(); if it's a String, you might need double.parse.
|
|
return double.parse(coordinate.toString());
|
|
}));
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
factory Geometry.fromJson(Map<String, dynamic> source) {
|
|
final geom = Geometry.fromMap(source);
|
|
return geom;
|
|
}
|
|
|
|
get latitude => coordinates[0][1];
|
|
get longitude => coordinates[0][0];
|
|
}
|
|
|
|
class Properties {
|
|
// Include all properties fields
|
|
final int locationId;
|
|
final String subLocId;
|
|
final double cp;
|
|
final String? name;
|
|
final String? address;
|
|
final String? phone;
|
|
final String? email;
|
|
final String? webcontents;
|
|
final String? videos;
|
|
final String? category;
|
|
final int? series;
|
|
final double? lat;
|
|
final double? lon;
|
|
final int? listOrder;
|
|
final String? photos;
|
|
final double? checkinRadious;
|
|
final bool? autoCheckin;
|
|
bool? selected = false;
|
|
bool? checkedin = false;
|
|
final double? checkinPoint;
|
|
final double? buyPoint;
|
|
final bool? hiddenLocation;
|
|
String? checkinImage;
|
|
String? buypointImage;
|
|
bool? forcedCheckin = false;
|
|
final String? tags;
|
|
|
|
Properties(
|
|
{required this.locationId,
|
|
required this.subLocId,
|
|
required this.cp,
|
|
this.name,
|
|
this.address,
|
|
this.phone,
|
|
this.email,
|
|
this.webcontents,
|
|
this.videos,
|
|
this.category,
|
|
this.series,
|
|
this.lat,
|
|
this.lon,
|
|
this.listOrder,
|
|
this.photos,
|
|
this.checkinRadious,
|
|
this.autoCheckin,
|
|
this.selected,
|
|
this.checkedin,
|
|
this.checkinPoint,
|
|
this.buyPoint,
|
|
this.hiddenLocation,
|
|
this.checkinImage,
|
|
this.buypointImage,
|
|
this.forcedCheckin,
|
|
this.tags});
|
|
|
|
factory Properties.fromJson(Map<String, dynamic> json) {
|
|
Properties prop;
|
|
try {
|
|
prop = Properties(
|
|
locationId: json['location_id'],
|
|
subLocId: json['sub_loc_id'],
|
|
cp: json['cp'],
|
|
name: json['name'] ?? '',
|
|
address: json['address'] ?? '',
|
|
phone: json['phone'] ?? '',
|
|
email: json['email'] ?? '',
|
|
webcontents: json['webcontents'] ?? '',
|
|
videos: json['videos'] ?? '',
|
|
category: json['category'] ?? '',
|
|
series: json['series'] ?? 0,
|
|
lat: json['lat'] ?? 0.0,
|
|
lon: json['lon'] ?? 0.0,
|
|
listOrder: json['list_order'] ?? 0,
|
|
photos: json['photos'] ?? '',
|
|
checkinRadious: json['checkin_radious'] ?? 0.0,
|
|
autoCheckin: json['auto_checkin'] == 0 ? false : true,
|
|
selected: json['selected'] == 0 ? false : true,
|
|
checkedin: json['checkedin'] == 0 ? false : true,
|
|
checkinPoint: json['checkin_point'] ?? 0.0,
|
|
buyPoint: json['buy_point'] ?? 0.0,
|
|
hiddenLocation: json['hidden_location'] == 0 ? false : true,
|
|
checkinImage: json['checkin_image'] ?? '',
|
|
buypointImage: json['buypoint_image'] ?? '',
|
|
forcedCheckin: json['forced_checkin'] == 0 ? false : true,
|
|
tags: json['tags'] ?? '');
|
|
//print("from json --- $prop");
|
|
} catch (e) {
|
|
//print("from json --- $e");
|
|
return Properties(locationId: 0, subLocId: '', cp: 0.0, name: '');
|
|
}
|
|
return prop;
|
|
}
|
|
|
|
factory Properties.toJson(Properties prop) {
|
|
return Properties(
|
|
locationId: prop.locationId,
|
|
subLocId: prop.subLocId,
|
|
cp: prop.cp,
|
|
name: prop.name,
|
|
address: prop.address,
|
|
phone: prop.phone,
|
|
email: prop.email,
|
|
webcontents: prop.webcontents,
|
|
videos: prop.videos,
|
|
category: prop.category,
|
|
series: prop.series,
|
|
lat: prop.lat,
|
|
lon: prop.lon,
|
|
listOrder: prop.listOrder,
|
|
photos: prop.photos,
|
|
checkinRadious: prop.checkinRadious,
|
|
autoCheckin: prop.autoCheckin,
|
|
selected: prop.selected,
|
|
checkedin: prop.checkedin,
|
|
checkinPoint: prop.checkinPoint,
|
|
buyPoint: prop.buyPoint,
|
|
hiddenLocation: prop.hiddenLocation,
|
|
checkinImage: prop.checkinImage,
|
|
buypointImage: prop.buypointImage,
|
|
forcedCheckin: prop.forcedCheckin,
|
|
tags: prop.tags);
|
|
}
|
|
|
|
Properties copyWith({
|
|
int? locationId,
|
|
String? subLocId,
|
|
double? cp,
|
|
String? name,
|
|
String? address,
|
|
String? phone,
|
|
String? email,
|
|
String? webcontents,
|
|
String? videos,
|
|
String? category,
|
|
int? series,
|
|
double? lat,
|
|
double? lon,
|
|
int? listOrder,
|
|
String? photos,
|
|
double? checkinRadious,
|
|
bool? autoCheckin,
|
|
bool? selected,
|
|
bool? checkedin,
|
|
double? checkinPoint,
|
|
double? buyPoint,
|
|
bool? hiddenLocation,
|
|
String? checkinImage,
|
|
String? buypointImage,
|
|
bool? forcedCheckin,
|
|
String? tags,
|
|
}) {
|
|
return Properties(
|
|
locationId: locationId ?? this.locationId,
|
|
subLocId: subLocId ?? this.subLocId,
|
|
cp: cp ?? this.cp,
|
|
name: name ?? this.name,
|
|
address: address ?? this.address,
|
|
phone: phone ?? this.phone,
|
|
email: email ?? this.email,
|
|
webcontents: webcontents ?? this.webcontents,
|
|
videos: videos ?? this.videos,
|
|
category: category ?? this.category,
|
|
series: series ?? this.series,
|
|
lat: lat ?? this.lat,
|
|
lon: lon ?? this.lon,
|
|
listOrder: listOrder ?? this.listOrder,
|
|
photos: photos ?? this.photos,
|
|
checkinRadious: checkinRadious ?? this.checkinRadious,
|
|
autoCheckin: autoCheckin ?? this.autoCheckin,
|
|
selected: selected ?? this.selected,
|
|
checkedin: checkedin ?? this.checkedin,
|
|
checkinPoint: checkinPoint ?? this.checkinPoint,
|
|
buyPoint: buyPoint ?? this.buyPoint,
|
|
hiddenLocation: hiddenLocation ?? this.hiddenLocation,
|
|
checkinImage: checkinImage ?? this.checkinImage,
|
|
buypointImage: buypointImage ?? this.buypointImage,
|
|
forcedCheckin: forcedCheckin ?? this.forcedCheckin,
|
|
tags: tags ?? this.tags,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return <String, dynamic>{
|
|
'locationId': locationId,
|
|
'subLocId': subLocId,
|
|
'cp': cp,
|
|
'name': name,
|
|
'address': address,
|
|
'phone': phone,
|
|
'email': email,
|
|
'webcontents': webcontents,
|
|
'videos': videos,
|
|
'category': category,
|
|
'series': series,
|
|
'lat': lat,
|
|
'lon': lon,
|
|
'listOrder': listOrder,
|
|
'photos': photos,
|
|
'checkinRadious': checkinRadious,
|
|
'autoCheckin': autoCheckin,
|
|
'selected': selected,
|
|
'checkedin': checkedin,
|
|
'checkinPoint': checkinPoint,
|
|
'buyPoint': buyPoint,
|
|
'hiddenLocation': hiddenLocation,
|
|
'checkinImage': checkinImage,
|
|
'buypointImage': buypointImage,
|
|
'forcedCheckin': forcedCheckin,
|
|
'tags': tags,
|
|
};
|
|
}
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
@override
|
|
String toString() {
|
|
return 'Properties(locationId: $locationId, subLocId: $subLocId, cp: $cp, name: $name, address: $address, phone: $phone, email: $email, webcontents: $webcontents, videos: $videos, category: $category, series: $series, lat: $lat, lon: $lon, listOrder: $listOrder, photos: $photos, checkinRadious: $checkinRadious, autoCheckin: $autoCheckin, selected: $selected, checkedin: $checkedin, checkinPoint: $checkinPoint, buyPoint: $buyPoint, hiddenLocation: $hiddenLocation, checkinImage: $checkinImage, buypointImage: $buypointImage, forcedCheckin: $forcedCheckin, tags: $tags)';
|
|
}
|
|
|
|
@override
|
|
bool operator ==(covariant Properties other) {
|
|
if (identical(this, other)) return true;
|
|
|
|
return other.locationId == locationId &&
|
|
other.subLocId == subLocId &&
|
|
other.cp == cp &&
|
|
other.name == name &&
|
|
other.address == address &&
|
|
other.phone == phone &&
|
|
other.email == email &&
|
|
other.webcontents == webcontents &&
|
|
other.videos == videos &&
|
|
other.category == category &&
|
|
other.series == series &&
|
|
other.lat == lat &&
|
|
other.lon == lon &&
|
|
other.listOrder == listOrder &&
|
|
other.photos == photos &&
|
|
other.checkinRadious == checkinRadious &&
|
|
other.autoCheckin == autoCheckin &&
|
|
other.selected == selected &&
|
|
other.checkedin == checkedin &&
|
|
other.checkinPoint == checkinPoint &&
|
|
other.buyPoint == buyPoint &&
|
|
other.hiddenLocation == hiddenLocation &&
|
|
other.checkinImage == checkinImage &&
|
|
other.buypointImage == buypointImage &&
|
|
other.forcedCheckin == forcedCheckin &&
|
|
other.tags == tags;
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return locationId.hashCode ^
|
|
subLocId.hashCode ^
|
|
cp.hashCode ^
|
|
name.hashCode ^
|
|
address.hashCode ^
|
|
phone.hashCode ^
|
|
email.hashCode ^
|
|
webcontents.hashCode ^
|
|
videos.hashCode ^
|
|
category.hashCode ^
|
|
series.hashCode ^
|
|
lat.hashCode ^
|
|
lon.hashCode ^
|
|
listOrder.hashCode ^
|
|
photos.hashCode ^
|
|
checkinRadious.hashCode ^
|
|
autoCheckin.hashCode ^
|
|
selected.hashCode ^
|
|
checkedin.hashCode ^
|
|
checkinPoint.hashCode ^
|
|
buyPoint.hashCode ^
|
|
hiddenLocation.hashCode ^
|
|
checkinImage.hashCode ^
|
|
buypointImage.hashCode ^
|
|
forcedCheckin.hashCode ^
|
|
tags.hashCode;
|
|
}
|
|
}
|