예제 #1
0
bool EnhanceNet::Connectivity_Processing (Db_File *fh)
{
	Connect_File *file;
	bool stat;

	stat = Network_Service::Connectivity_Processing (fh);
		
	file = (Connect_File *) fh;

	if (!stat) {
		if (file->Node () == 0) return (false);

	} else if (type_flag || Connect_Code (file->Type ()) == NO_TYPE) {

		Connect_Data *connect_ptr = connect_data.New_Record ();

		connect_ptr->Type (NO_TYPE);
	}

	//---- save the record to the database ----

	if (First_Record ()) {
		if (!connect_db.Max_Records (file->Num_Records ())) {
			Error ("Insufficient Memory for Lane Connectivity Database");
		}
	}
	connect_db.Copy_Fields (file);

	if (!connect_db.Add_Record ()) {
		Error ("Writing Lane Connectivity Database");
	}
	return (stat);
}
예제 #2
0
int Data_Service::Put_Connect_Data (Connect_File &file, Connect_Data &data)
{
    Dir_Data *dir_ptr;
    Link_Data *link_ptr;

    dir_ptr = &dir_array [data.Dir_Index ()];
    link_ptr = &link_array [dir_ptr->Link ()];

    file.Link (link_ptr->Link ());
    file.Dir (dir_ptr->Dir ());
    file.Lanes (Make_Lane_Range (dir_ptr, data.Low_Lane (), data.High_Lane ()));

    dir_ptr = &dir_array [data.To_Index ()];
    link_ptr = &link_array [dir_ptr->Link ()];

    file.To_Link (link_ptr->Link ());
    file.To_Lanes (Make_Lane_Range (dir_ptr, data.To_Low_Lane (), data.To_High_Lane ()));

    file.Type (data.Type ());
    file.Penalty (data.Penalty ());
    file.Speed (UnRound (data.Speed ()));
    file.Capacity (data.Capacity ());
    file.Notes (data.Notes ());

    if (!file.Write ()) {
        Error (String ("Writing %s") % file.File_Type ());
    }
    return (1);
}
예제 #3
0
bool Data_Service::Get_Connect_Data (Connect_File &file, Connect_Data &connect_rec)
{
	int link, dir, node, dir_index, to_index, lanes, low, high;

	Link_Data *link_ptr;
	Int_Map_Itr map_itr;

	//---- check/convert the link number and direction ----
	
	link = file.Link ();
	dir = file.Dir ();

	link_ptr = Set_Link_Direction (file, link, dir);

	if (link_ptr == 0) return (false);

	if (dir) {
		dir_index = link_ptr->BA_Dir ();
		node = link_ptr->Anode ();
	} else {
		dir_index = link_ptr->AB_Dir ();
		node = link_ptr->Bnode ();
	}
	if (dir_index < 0) {
		Warning (String ("Connection %d Link %d Direction %s was Not Found") % Progress_Count () % 
			link_ptr->Link () % ((dir) ? "BA" : "AB"));
		return (false);
	}
	connect_rec.Dir_Index (dir_index);

	//---- convert the to-link number ----

	link = file.To_Link ();

	map_itr = link_map.find (link);
	if (map_itr == link_map.end ()) {
		Warning (String ("Connection %d Link %d was Not Found") % Progress_Count () % link);
		return (false);
	}
	link = map_itr->second;

	link_ptr = &link_array [link];

	if (link_ptr->Anode () == node) {
		to_index = link_ptr->AB_Dir ();
	} else if (link_ptr->Bnode () == node) {
		to_index = link_ptr->BA_Dir ();
	} else {
		Node_Data *ptr = &node_array [node];
		Warning (String ("Connection %d Node %d is Not on Link %d") % Progress_Count () % 
			ptr->Node () % link_ptr->Link ());
		return (false);
	}
	connect_rec.To_Index (to_index);

	//---- lane numbers ----

	lanes = file.Lanes ();

	if (file.Version () <= 40 && lanes > 0) {
		low = lanes - 1;
		high = file.In_High () - 1;
		if (high < low) high = low;
	} else {
		Convert_Lane_Range (dir_index, lanes, low, high);
	}
	connect_rec.Low_Lane (low);
	connect_rec.High_Lane (high);

	lanes = file.To_Lanes ();

	if (file.Version () <= 40 && lanes > 0) {
		low = lanes - 1;
		high = file.Out_High () - 1;
		if (high < low) high = low;
	} else {
		Convert_Lane_Range (to_index, lanes, low, high);
	}
	connect_rec.To_Low_Lane (low);
	connect_rec.To_High_Lane (high);

	//---- optional fields ----
	
	connect_rec.Type (file.Type ());
	connect_rec.Penalty (file.Penalty ());
	connect_rec.Speed (file.Speed ());
	connect_rec.Capacity (file.Capacity ());
	connect_rec.Notes (file.Notes ());

	//---- check for duplicate records ----

	if (file.Version () <= 40) {
		Int2_Map_Itr map2_itr;

		//max_in = dir_ptr->Thru () + dir_ptr->Left () + dir_ptr->Right ();
		//in_bear = dir_ptr->Out_Bearing ();

		//max_out = dir_ptr->Thru () + dir_ptr->Left () + dir_ptr->Right ();
		//out_bear = dir_ptr->In_Bearing ();

		//---- read and save the data ----

		//int num, node_num, link, dir, in_link, out_link, max_in, max_out, in_bear, out_bear;
		//int in_low, in_high, out_low, out_high, type, penalty, speed, capacity, change;
		//if (type == 0 && compass.Num_Points () > 0) {
		//	change = compass.Change (in_bear, out_bear) * 360 / compass.Num_Points ();

		//	if (change >= -45 && change <= 45) {
		//		type = THRU;
		//	} else if (change < -165 || change > 165) {
		//		type = UTURN;
		//	} else if (change < 0) {
		//		type = LEFT;
		//	} else {
		//		type = RIGHT;
		//	}
		//}

		map2_itr = connect_map.find (Int2_Key (connect_rec.Dir_Index (), connect_rec.To_Index ()));

		if (map2_itr != connect_map.end ()) {
			Connect_Data *connect_ptr;

			//---- update optional fields ----

			connect_ptr = &connect_array [map2_itr->second];

			//---- merge the entry lane codes ----

			if (connect_rec.Low_Lane () < connect_ptr->Low_Lane ()) {
				connect_ptr->Low_Lane (connect_rec.Low_Lane ());
			}
			if (connect_rec.High_Lane () > connect_ptr->High_Lane ()) {
				connect_ptr->High_Lane (connect_rec.High_Lane ());
			}

			//---- merge the exit lane codes ----
			
			if (connect_rec.To_Low_Lane () < connect_ptr->To_Low_Lane ()) {
				connect_ptr->To_Low_Lane (connect_rec.To_Low_Lane ());
			}
			if (connect_rec.To_High_Lane () > connect_ptr->To_High_Lane ()) {
				connect_ptr->To_High_Lane (connect_rec.To_High_Lane ());
			}

			//---- merge the optional data ----

			if (connect_rec.Type () > connect_ptr->Type ()) {
				connect_ptr->Type (connect_rec.Type ());
			}
			if (connect_rec.Penalty () > connect_ptr->Penalty ()) {
				connect_ptr->Penalty (connect_rec.Penalty ());
			}
			if (connect_rec.Speed () > connect_ptr->Speed ()) {
				connect_ptr->Speed (connect_rec.Speed ());
			}
			connect_ptr->Capacity (connect_ptr->Capacity () + connect_rec.Capacity ());
			return (false);
		}
	}
	return (true);
}
예제 #4
0
bool Relocate::Get_Connect_Data (Connect_File &file, Connect_Data &connect_rec)
{
	if (!target_flag) {
		if (!Data_Service::Get_Connect_Data (file, connect_rec)) return (false);
		return (true);
	}
	int link, dir, node, dir_index, to_index, lanes, low, high;
	bool new_flag;

	Link_Data *link_ptr;
	Int_Map_Itr map_itr;

	//---- check/convert the link number and direction ----
	
	link = file.Link ();
	dir = file.Dir ();
	new_flag = false;

	map_itr = link_map.find (link);
	if (map_itr == link_map.end ()) {
		Warning (String ("Connection %d Link %d was Not Found") % Progress_Count () % link);
		return (false);
	}
	
	link_ptr = &link_array [map_itr->second];

	if (link_ptr->Divided () == 3) {
		map_itr = target_link_map.find (link);
		if (map_itr != target_link_map.end ()) {
			link_ptr = &link_array [map_itr->second];
			new_flag = true;
		}
	} else if (link_ptr->Divided () == 2) {
		new_flag = true;
	}
	if (dir) {
		dir_index = link_ptr->BA_Dir ();
		node = link_ptr->Anode ();
	} else {
		dir_index = link_ptr->AB_Dir ();
		node = link_ptr->Bnode ();
	}
	if (dir_index < 0) {
		Warning (String ("Connection %d Link %d Direction %s was Not Found") % Progress_Count () % 
			link_ptr->Link () % ((dir) ? "BA" : "AB"));
		return (false);
	}
	connect_rec.Dir_Index (dir_index);
	connect_rec.Type (file.Type ());

	//---- convert the to-link number ----

	link = file.To_Link ();

	map_itr = link_map.find (link);
	if (map_itr == link_map.end ()) {
		Warning (String ("Connection %d Link %d was Not Found") % Progress_Count () % link);
		return (false);
	}
	link = map_itr->second;

	link_ptr = &link_array [link];

	if (link_ptr->Divided () == 3) {
		map_itr = target_link_map.find (link);
		if (map_itr != target_link_map.end ()) {
			link_ptr = &link_array [map_itr->second];
			new_flag = true;
		}
	} else if (link_ptr->Divided () == 2) {
		new_flag = true;
	}
	if (!new_flag) return (false);

	if (link_ptr->Anode () == node) {
		to_index = link_ptr->AB_Dir ();
	} else if (link_ptr->Bnode () == node) {
		to_index = link_ptr->BA_Dir ();
	} else {
		Node_Data *ptr = &node_array [node];
		Warning (String ("Connection %d Node %d is Not on Link %d") % Progress_Count () % 
			ptr->Node () % link_ptr->Link ());
		return (false);
	}
	if (to_index < 0) {
		Node_Data *ptr = &node_array [node];

		Warning (String ("Connection %d Link %d Node %d was Not Found") % Progress_Count () % 
			link_ptr->Link () % ptr->Node ());
		return (false);
	}
	connect_rec.To_Index (to_index);
	connect_rec.Node (node);

	//---- lane numbers ----

	lanes = file.Lanes ();

	Convert_Lane_Range (dir_index, lanes, low, high);
	
	connect_rec.Low_Lane (low);
	connect_rec.High_Lane (high);

	lanes = file.To_Lanes ();

	Convert_Lane_Range (to_index, lanes, low, high);

	connect_rec.To_Low_Lane (low);
	connect_rec.To_High_Lane (high);

	//---- optional fields ----
	
	connect_rec.Penalty (file.Penalty ());
	connect_rec.Speed (file.Speed ());
	connect_rec.Capacity (file.Capacity ());

	return (true);
}