Пример #1
0
bool Data_Service::Get_Trip_Data (Trip_File &file, Trip_Data &trip_rec, int partition)
{
	int hhold, lvalue;
	Int_Map_Itr map_itr;
	Vehicle_Index veh_index;
	Vehicle_Map_Itr veh_itr;

	//---- check the household id ----

	hhold = file.Household ();
	if (hhold < 1) return (false);

	trip_rec.Household (hhold);

	trip_rec.Person (file.Person ());
	trip_rec.Tour (MAX (file.Tour (), 1));
	trip_rec.Trip (file.Trip ());

	trip_rec.Start (file.Start ());
	trip_rec.End (file.End ());

	//---- convert the origin ----

	lvalue = file.Origin ();

	map_itr = location_map.find (lvalue);

	if (map_itr == location_map.end ()) {
		Warning (String ("Trip %d Origin %d was Not Found") % Progress_Count () % lvalue);
		return (false);
	}
	trip_rec.Origin (map_itr->second);

	//---- convert the destination ----

	lvalue = file.Destination ();

	map_itr = location_map.find (lvalue);

	if (map_itr == location_map.end ()) {
		Warning (String ("Trip %d Destination %d was Not Found") % Progress_Count () % lvalue);
		return (false);
	}
	trip_rec.Destination (map_itr->second);

	lvalue = file.Vehicle ();

	if (file.Version () <= 40) {
		lvalue = Fix_Vehicle_ID (lvalue);
	}
	if (lvalue > 0) {
		veh_index.Household (hhold);
		veh_index.Vehicle (lvalue);

		veh_itr = vehicle_map.find (veh_index);
		if (veh_itr == vehicle_map.end ()) {
			Warning (String ("Trip %d Vehicle %d was Not Found") % Progress_Count () % lvalue);
			return (false);
		}
		lvalue = veh_itr->second;
	} else {
		lvalue = -1;
	}
	trip_rec.Vehicle (lvalue);

	if (file.Version () <= 40) {
		trip_rec.Mode (Trip_Mode_Map (file.Mode ()));
	} else {
		trip_rec.Mode (file.Mode ());
	}
	trip_rec.Purpose (file.Purpose ());
	trip_rec.Constraint (file.Constraint ());
	trip_rec.Passengers (file.Passengers ());

	trip_rec.Type (file.Type ());

	if (file.Partition_Flag ()) {
		trip_rec.Partition (file.Partition ());
	} else {
		trip_rec.Partition (partition);
	}	
	//trip_rec.Notes (file.Notes ());

	return (true);
}