import 'package:geojson_vi/geojson_vi.dart'; import 'package:latlong2/latlong.dart'; class Location { int? location_id; String? location_name; String? category; String? zip; String? address; String? prefecture; String? area; String? city; double? latitude; double? longitude; String? photos; String? videos; String? webcontents; String? status; String? portal; String? group; String? phone; String? fax; String? email; String? facility; String? remark; String? tags; String? event_name; bool? event_active; bool? hidden_location; bool? auto_checkin; int? checkin_radius; int? checkin_point; int? buy_point; String? evaluation_value; bool? shop_closed; bool? shop_shutdown; String? opening_hours_mon; String? opening_hours_tue; String? opening_hours_wed; String? opening_hours_thu; String? opening_hours_fri; String? opening_hours_sat; String? opening_hours_sun; String? parammeters; DateTime? created_at; LatLng? geometry; GeoJSONGeometry? multipoint; Location({ this.location_id, this.location_name, this.category, this.zip, this.address, this.prefecture, this.area, this.city, this.latitude, this.longitude, this.photos, this.videos, this.webcontents, this.status, this.portal, this.group, this.phone, this.fax, this.email, this.facility, this.remark, this.tags, this.event_name, this.event_active, this.hidden_location, this.auto_checkin, this.checkin_radius, this.checkin_point, this.buy_point, this.evaluation_value, this.shop_closed, this.shop_shutdown, this.opening_hours_mon, this.opening_hours_tue, this.opening_hours_wed, this.opening_hours_thu, this.opening_hours_fri, this.opening_hours_sat, this.opening_hours_sun, this.parammeters, this.created_at, this.geometry, this.multipoint, }); factory Location.fromMap(Map json){ bool is_event_active = json['event_active'] == 0 ? false : true; bool is_hidden_location = json['hidden_location'] == 0 ? false : true; bool is_auto_checkin = json['auto_checkin'] == 0 ? false : true; bool is_shop_closed = json['shop_closed'] == 0 ? false : true; bool is_shop_shutdown = json['shop_shutdown'] == 0 ? false : true; return Location( location_id: json['location_id'], location_name: json['location_name'], category: json['category'], zip: json['zip'], address: json['address'], prefecture: json['prefecture'], area: json['area'], city: json['city'], latitude: json['latitude'], longitude: json['longitude'], photos: json['photos'], videos: json['videos'], webcontents: json['webcontents'], status: json['status'], portal: json['portal'], group: json['group'], phone: json['phone'], fax: json['fax'], email: json['email'], facility: json['facility'], remark: json['remark'], tags: json['tags'], event_name: json['event_name'], event_active: is_event_active, hidden_location: is_hidden_location, auto_checkin: is_auto_checkin, checkin_radius: json['checkin_radius'], checkin_point: json['checkin_point'], buy_point: json['buy_point'], evaluation_value: json['evaluation_value'], shop_closed: is_shop_closed, shop_shutdown: is_shop_shutdown, opening_hours_mon: json['opening_hours_mon'], opening_hours_tue: json['opening_hours_tue'], opening_hours_wed: json['opening_hours_wed'], opening_hours_thu: json['opening_hours_thu'], opening_hours_fri: json['opening_hours_fri'], opening_hours_sat: json['opening_hours_sat'], opening_hours_sun: json['opening_hours_sun'], parammeters: json['parammeters'] ); } factory Location.fromGeoJSONFeture(GeoJSONFeature feature){ GeoJSONMultiPoint geom = feature.geometry as GeoJSONMultiPoint; LatLng geomVal = LatLng(geom.coordinates[0][1], geom.coordinates[0][0]); return Location( location_id: feature.properties!["location_id"], location_name: feature.properties!["location_name"], category: feature.properties!["category"], zip: feature.properties!["zip"], address: feature.properties!["address"], prefecture: feature.properties!["prefecture"], area: feature.properties!["area"], city: feature.properties!["city"], latitude: feature.properties!["latitude"], longitude: feature.properties!["longitude"], phone: feature.properties!["phone"], videos: feature.properties!["videos"], webcontents: feature.properties!["webcontents"], status: feature.properties!["status"], portal: feature.properties!["portal"], group: feature.properties!["group"], photos: feature.properties!["photos"], fax: feature.properties!["fax"], email: feature.properties!["email"], facility: feature.properties!["facility"], remark: feature.properties!["remark"], tags: feature.properties!["tags"], event_name: feature.properties!["event_name"], event_active: feature.properties!["event_active"], hidden_location: feature.properties!["hidden_location"], auto_checkin: feature.properties!["auto_checkin"], checkin_radius: feature.properties!["checkin_radius"], checkin_point: feature.properties!["checkin_point"], buy_point: feature.properties!["buy_point"], evaluation_value: feature.properties!["evaluation_value"], shop_closed: feature.properties!["shop_closed"], shop_shutdown: feature.properties!["shop_shutdown"], opening_hours_mon: feature.properties!["opening_hours_mon"], opening_hours_tue: feature.properties!["opening_hours_tue"], opening_hours_wed: feature.properties!["opening_hours_wed"], opening_hours_thu: feature.properties!["opening_hours_thu"], opening_hours_fri: feature.properties!["opening_hours_fri"], opening_hours_sat: feature.properties!["opening_hours_sat"], opening_hours_sun: feature.properties!["opening_hours_sun"], parammeters: feature.properties!["parammeters"], created_at: DateTime.parse(feature.properties!["created_at"]), geometry: geomVal, multipoint: feature.geometry ); } Map toMap(){ int is_active = event_active == false ? 0 : 1; int is_hidden = hidden_location == false ? 0 : 1; int is_auto = auto_checkin == false ? 0 : 1; int is_closed = shop_closed == false ? 0 : 1; int is_shuldown = shop_shutdown == false ? 0 : 1; return { 'location_id': location_id, 'location_name': location_name, 'category': category, 'zip': zip, 'address': address, 'prefecture': prefecture, 'area': area, 'city': city, 'latitude': latitude, 'longitude': longitude, 'phone': phone, 'videos': videos, 'webcontents': webcontents, 'status': status, 'portal': portal, 'group': group, 'photos':photos, 'fax': fax, 'email': email, 'facility': facility, 'remark': remark, 'tags': tags, 'event_name': event_name, 'event_active': event_active, 'hidden_location': hidden_location, 'auto_checkin': auto_checkin, 'checkin_radius': checkin_radius, 'checkin_point': checkin_point, 'buy_point': buy_point, 'evaluation_value': evaluation_value, 'shop_closed': shop_closed, 'shop_shutdown': shop_shutdown, 'opening_hours_mon': opening_hours_mon, 'opening_hours_tue': opening_hours_tue, 'opening_hours_wed': opening_hours_wed, 'opening_hours_thu': opening_hours_thu, 'opening_hours_fri': opening_hours_fri, 'opening_hours_sat': opening_hours_sat, 'opening_hours_sun': opening_hours_sun, 'parammeters': parammeters }; } GeoJSONFeature toGeoFeature(){ GeoJSONMultiPoint geom = multipoint as GeoJSONMultiPoint; return GeoJSONFeature( geom, properties: { 'location_id': location_id, 'location_name': location_name, 'category': category, 'zip': zip, 'address': address, 'prefecture': prefecture, 'area': area, 'city': city, 'latitude': latitude, 'longitude': longitude, 'phone': phone, 'videos': videos, 'webcontents': webcontents, 'status': status, 'portal': portal, 'group': group, 'photos':photos, 'fax': fax, 'email': email, 'facility': facility, 'remark': remark, 'tags': tags, 'event_name': event_name, 'event_active': event_active, 'hidden_location': hidden_location, 'auto_checkin': auto_checkin, 'checkin_radius': checkin_radius, 'checkin_point': checkin_point, 'buy_point': buy_point, 'evaluation_value': evaluation_value, 'shop_closed': shop_closed, 'shop_shutdown': shop_shutdown, 'opening_hours_mon': opening_hours_mon, 'opening_hours_tue': opening_hours_tue, 'opening_hours_wed': opening_hours_wed, 'opening_hours_thu': opening_hours_thu, 'opening_hours_fri': opening_hours_fri, 'opening_hours_sat': opening_hours_sat, 'opening_hours_sun': opening_hours_sun, 'parammeters': parammeters, 'created_at': created_at, } ); } }