Exemple #1
0
void Data_Service::Read_Locations (void)
{
	Location_File *file = (Location_File *) System_File_Handle (LOCATION);

	int num;
	bool zone_flag = System_Data_Flag (ZONE);

	Int_Map_Stat map_stat;
	Location_Data location_rec;

	//---- store the location data ----

	Show_Message (String ("Reading %s -- Record") % file->File_Type ());
	Set_Progress ();

	Initialize_Locations (*file);

	while (file->Read ()) {
		Show_Progress ();

		location_rec.Clear ();

		if (Get_Location_Data (*file, location_rec)) {
			map_stat = location_map.insert (Int_Map_Data (location_rec.Location (), (int) location_array.size ()));

			if (!map_stat.second) {
				Warning ("Duplicate Location Number = ") << location_rec.Location ();
				continue;
			} else {
				if (!file->Setback_Flag () && location_rec.Setback () == 0) {
					location_rec.Setback (Internal_Units (100.0, FEET));
				}
				location_array.push_back (location_rec);

				if (!zone_flag && location_rec.Zone () > Max_Zone_Number ()) {
					Max_Zone_Number (location_rec.Zone ());
				}
			}
		}
	}
	End_Progress ();
	file->Close ();

	Print (2, String ("Number of %s Records = %d") % file->File_Type () % Progress_Count ());

	num = (int) location_array.size ();

	if (num && num != Progress_Count ()) {
		Print (1, String ("Number of %s Data Records = %d") % file->File_ID () % num);
	}
	if (num > 0) System_Data_True (LOCATION);
}
Exemple #2
0
void NewFormat::Read_Routes (void)
{
	String field;
	int i, node, route, route_fld, mode_fld, ttime_fld, name_fld, note_fld, node_fld, dwell_fld, time_fld, spd_fld;
	int head_fld [24], offset_fld [24], ttim_fld [24];

	Int_Map_Stat map_stat;
	Int_Map_Itr map_itr;
	Route_Header route_rec, *route_ptr;

	//---- process the route header file ----

	Show_Message (String ("Reading %s -- Record") % route_header.File_Type ());
	Set_Progress ();

	route_fld = route_header.Required_Field ("ROUTE", "LINE");
	mode_fld = route_header.Required_Field ("MODE", "TYPE");
	ttime_fld = route_header.Optional_Field ("TTIME", "TIME", "MIN_TIME");
	name_fld = route_header.Optional_Field ("NAME", "ROUTE_NAME", "RTNAME", "DESCRIPTION");
	note_fld = route_header.Optional_Field (NOTES_FIELD_NAMES);
	
	for (i=1; i <= route_periods; i++) {
		field ("HEADWAY_%d") % i;
		head_fld [i-1] = route_header.Required_Field (field.c_str ());

		field ("OFFSET_%d") % i;
		offset_fld [i-1] = route_header.Optional_Field (field.c_str ());

		field ("TTIME_%d") % i;
		ttim_fld [i-1] = route_header.Optional_Field (field.c_str ());
		if (ttim_fld [i-1] < 0) ttim_fld [i-1] = ttime_fld;
	}

	while (route_header.Read ()) {
		Show_Progress ();
		route_rec.Clear ();

		route_rec.Route (route_header.Get_Integer (route_fld));
		if (route_rec.Route () == 0) continue;

		//---- set the parking type ----
		
		route_rec.Mode (Transit_Code (route_header.Get_String (mode_fld)));
		route_rec.Name (route_header.Get_String (name_fld));
		route_rec.Notes (route_header.Get_String (note_fld));

		switch (route_rec.Mode ()) {
			case LOCAL_BUS:
				route_rec.Veh_Type (4);
				break;
			case EXPRESS_BUS:
				route_rec.Veh_Type (5);
				break;
			case BRT:
				route_rec.Veh_Type (6);
				break;
			case STREETCAR:
				route_rec.Veh_Type (7);
				break;
			case LRT:
				route_rec.Veh_Type (8);
				break;
			case RAPIDRAIL:
				route_rec.Veh_Type (9);
				break;
			case REGIONRAIL:
				route_rec.Veh_Type (10);
				break;
		}
		if (veh_type_array.size () > 0) {
			route_rec.Veh_Type (VehType40_Map (route_rec.Veh_Type (), 0));

			if (route_rec.Veh_Type () > 0) {
				Int_Map_Itr map_itr = veh_type_map.find (route_rec.Veh_Type ());
				if (map_itr == veh_type_map.end ()) {
					Warning (String ("Transit Vehicle Type %d was Not Found") % route_rec.Veh_Type ());
					route_rec.Veh_Type (0);
				} else {
					route_rec.Veh_Type (map_itr->second);
				}
			} else {
				route_rec.Veh_Type (0);
			}
		}

		for (i=0; i < route_periods; i++) {
			Route_Period period_rec;

			period_rec.Headway (route_header.Get_Time (head_fld [i]));
			period_rec.Offset (route_header.Get_Time (offset_fld [i]));
			period_rec.TTime (route_header.Get_Integer (ttim_fld [i]));

			route_rec.periods.push_back (period_rec);
		}
		map_stat = route_map.insert (Int_Map_Data (route_rec.Route (), (int) route_nodes_array.size ()));

		if (!map_stat.second) {
			Warning ("Duplicate Route Number = ") << route_rec.Route ();
		} else {
			route_nodes_array.push_back (route_rec);
		}
	}
	End_Progress ();

	Print (2, String ("Number of %s Records = %d") % route_header.File_Type () % Progress_Count ());

	//---- process the route nodes file ----

	Show_Message (String ("Reading %s -- Record") % route_nodes.File_Type ());
	Set_Progress ();

	route_fld = route_nodes.Required_Field ("ROUTE", "LINE");
	node_fld = route_nodes.Required_Field ("NODE", "STOP");
	dwell_fld = route_nodes.Optional_Field ("DWELL", "DWELL_TIME", "STOP_TIME", "STOPTIME");
	time_fld = route_nodes.Optional_Field ("TIME", "TTIME", "RUNTIME", "RUN_TIME");
	spd_fld = route_nodes.Optional_Field ("SPEED", "SPD", "RUNSPD", "RUN_SPD", "RUN_SPEED");

	while (route_nodes.Read ()) {
		Show_Progress ();

		route = route_nodes.Get_Integer (route_fld);

		map_itr = route_map.find (route);
		if (map_itr == route_map.end ()) {
			Warning (String ("Route Nodes Route %d was Not Found in the Route Header File") % route);
			continue;
		}
		route_ptr = &route_nodes_array [map_itr->second];

		Route_Node node_rec;

		node = route_nodes.Get_Integer (node_fld);
		if (node < 0) {
			node_rec.Type (NO_STOP);
			node = -node;
		} else {
			node_rec.Type (STOP);
		}
		map_itr = node_map.find (node);
		if (map_itr == node_map.end ()) {
			Warning (String ("Route %d Node %d was Not Found") % route % node);
			continue;
		}
		node_rec.Node (map_itr->second);
		node_rec.Dwell (Dtime (route_nodes.Get_Integer (dwell_fld), SECONDS));
		node_rec.Time (Dtime (route_nodes.Get_Integer (time_fld), SECONDS));
		node_rec.Speed (Internal_Units (route_nodes.Get_Double (spd_fld), MPS));

		route_ptr->nodes.push_back (node_rec);
	}
	End_Progress ();

	Print (2, String ("Number of %s Records = %d") % route_nodes.File_Type () % Progress_Count ());
}
Exemple #3
0
int Db_Base::Add_Field (const char *name, Field_Type type, double size, Units_Type units, bool binary, Nest_Type nest, int offset) 
{
	if (Dbase_Format () == DEFAULT_FORMAT) {
		Dbase_Format (DEFAULT_FORMAT);
	}
	if (field.capacity () == 0) {
		field.reserve (10);
	}
	if (time_format == NO_UNITS) {
		time_format = Static_Service::Time_Format ();
		if (type == DB_TIME && units == NO_UNITS) {
			units = time_format;
		}
	}
	int length, num;
	Field_Itr itr;

	switch (Dbase_Format ()) {
		case COMMA_DELIMITED:
		case SPACE_DELIMITED:
		case TAB_DELIMITED:
		case CSV_DELIMITED:
		case VERSION3:
			num = 1;
			length = 0;

			for (itr = field.begin (); itr != field.end (); itr++) {
				if ((nest != NESTED && !itr->Nested ()) || itr->Nest () == nest) {
					length += itr->Width () + 1;
					num++;
				}
			}
			if (binary) {
				Binary_Text_Size (type, &size);
			}
			length += (int) size;
			if (offset <= 0) offset = num;
			break;
		case UNFORMATED:
		case BINARY:
		case FIXED_COLUMN:
		case DBASE:
		case ARCVIEW:
		case SQLITE3:
		case TPPLUS:
		case TRANSCAD:
		default:
			if (offset < 0) {
				offset = (Dbase_Format () == DBASE || Dbase_Format () == ARCVIEW) ? 1 : 0;

				for (itr = field.begin (); itr != field.end (); itr++) {
					if ((nest != NESTED && !itr->Nested ()) || itr->Nest () == nest) {
						length = itr->Offset () + itr->Width ();
						if (offset < length) offset = length;
					}
				}
			}
			if (binary) {
				if (Record_Format () != BINARY) {
					Binary_Text_Size (type, &size);
				}
			} else if (Record_Format () == BINARY) {
				Text_Binary_Size (type, &size);
			}
			if (type == DB_TIME && Record_Format () == BINARY) {
				units = SECONDS;
			}
			length = offset + (int) size;
			break;
	}

	//---- convert to internal units ----

	if (File_Access () == CREATE) Internal_Units (1.0, &units);

	Db_Field fld (name, type, offset, size, units, nest);

	num = (int) field.size ();
	field.push_back (fld);

	Nested (nest);

	if (!Record_Size (length)) return (-1);

	return (num);
}
Exemple #4
0
bool Db_Base::Read_Field (Db_Field *fld, void *data, Field_Type type)
{
	if (data == 0) return (Status (NULL_POINTER));
	
	//---- initialize the data field ----

	switch (type) {
		case DB_INTEGER:
			*((int *) data) = 0;
			break;
		case DB_DOUBLE:
			*((double *) data) = 0.0;
			break;
		case DB_STRING:
			((string *) data)->clear ();
			break;
		case DB_TIME:
			*((Dtime *) data) = 0;
			break;
		default:
			return (Status (DB_ERROR));
	}
	if (fld == 0) return (Status (NO_FIELD, false));

	Nested (fld->Nested ());

	char *field = Record_String ();

	if (field == 0) return (Status (RECORD_SIZE));

	Field_Type fld_type;
	bool asc_flag = true;
	int len, lvalue = 0;
	double dvalue = 0.0;
	String svalue;
	Dtime tvalue = 0;

	int size = fld->Width ();
	int offset = fld->Offset ();

	switch (Record_Format ()) {
		case BINARY:
			if (fld->Type () != DB_STRING) {
				field += offset;
				asc_flag = false;
				break;
			} else {
				len = (int) strlen (field + offset);
				if (len < size) size = len;
			}
		case FIXED_COLUMN:
			svalue.assign (field + offset, size);
			svalue.Clean ();
			break;
		case COMMA_DELIMITED:
		case SPACE_DELIMITED:
		case TAB_DELIMITED:
		case CSV_DELIMITED:
			svalue (fld->Buffer ());
			size = (int) svalue.size ();
			break;
		default:
			svalue  = Get_Field_Number (offset);
			size = (int) svalue.size ();
			break;
	}

	//---- read the field from the current record ----

	switch (fld->Type ()) {
		default:
			return (Status (DB_ERROR));

		case DB_INTEGER:
			if (asc_flag) {
				lvalue = svalue.Integer ();
			} else if (size == sizeof (int)) {
				lvalue = *((int *) field);
			} else if (size == sizeof (short)) {
				lvalue = *((short *) field);
			} else if (size == sizeof (char)) {
				lvalue = *((char *) field);
			} else {
				return (Status (FIELD_BYTES));
			}
			fld_type = DB_INTEGER;
			break;
			
		case DB_UNSIGNED:
			if (asc_flag) {
				lvalue = svalue.Integer ();
			} else if (size == sizeof (int)) {
				lvalue = *((unsigned int *) field);
			} else if (size == sizeof (short)) {
				lvalue = *((unsigned short *) field);
			} else if (size == sizeof (char)) {
				lvalue = *((unsigned char *) field);
			} else {
				return (Status (FIELD_BYTES));
			}
			fld_type = DB_INTEGER;
			break;
			
		case DB_DOUBLE:
			if (asc_flag) {
				dvalue = svalue.Double ();
			} else if (size == sizeof (double)) {
				dvalue = *((double *) field);
			} else if (size == sizeof (float)) {
				dvalue = *((float *) field);
			} else {
				return (Status (FIELD_BYTES));
			}
			fld_type = DB_DOUBLE;
			break;
			
		case DB_FIXED:
			if (asc_flag) {
				dvalue = svalue.Double ();
				if (svalue.find ('.') == 0) {
					dvalue = dvalue / pow (10.0, fld->Decimal ());
				}
			} else {
				if (size == sizeof (int)) {
					lvalue = *((int *) field);
				} else if (size == sizeof (short)) {
					lvalue = *((short *) field);
				} else if (size == sizeof (char)) {
					lvalue = *((char *) field);
				} else {
					return (Status (FIELD_BYTES));
				}
				dvalue = (double) lvalue / pow (10.0, fld->Decimal ());
			}
			fld_type = DB_DOUBLE;
			break;
			
		case DB_STRING:
			fld_type = DB_STRING;
			break;

		case DB_CHAR:
			if (asc_flag) {
				if (svalue.empty ()) {
					svalue = " ";
				}
			} else {
				if (*field == '\0') {
					svalue = " ";
				} else {
					svalue.insert (0, field, 1);
				}
			}
			fld_type = DB_STRING;
			break;
			
		case DB_TIME:
			if (asc_flag) {
				tvalue.Time_String (svalue, fld->Units ());
			} else if (size == sizeof (Dtime)) {
				tvalue = *((int *) field);
			} else if (size == sizeof (short)) {
				tvalue = *((short *) field);
			} else {
				return (Status (FIELD_BYTES));
			}
			fld_type = DB_TIME;
			break;
	}

	//---- convert to internal units ----

	if (fld->Units () != NO_UNITS) {
		if (fld_type == DB_INTEGER) {
			lvalue = Internal_Units (lvalue, fld->Units ());
		} else if (fld_type == DB_DOUBLE) {
			dvalue = Internal_Units (dvalue, fld->Units ());
		} else if (fld->Units () < SECONDS || fld->Units () > TIME_CODE) {
			if (fld_type == DB_STRING && fld->Units () >= FACILITY_CODE) {
				if (type == DB_INTEGER) {
					lvalue = Internal_Units (svalue, fld->Units ());
					if (lvalue < -1) return (Status (FIELD_UNITS));
					if (lvalue >= 0) fld_type = DB_INTEGER;
				}
			} else {
				return (Status (FIELD_UNITS));
			}
		}
	}

	//---- convert to the output data type ----

	switch (type) {
		case DB_INTEGER:
			switch (fld_type) {
				case DB_INTEGER:
					*((int *) data) = lvalue;
					break;
				case DB_DOUBLE:
					*((int *) data) = DTOI (dvalue);
					break;
				case DB_STRING:
					if (svalue [0] < '0' || svalue [0] > '9' || svalue.find_first_of ("@:") != svalue.npos) {
						*((int *) data) = (int) Dtime (svalue);
					} else {
						*((int *) data) = svalue.Integer ();
					}
					break;
				case DB_TIME:
					*((int *) data) = (int) tvalue;
					break;
				default:
					return (Status (DB_ERROR));
			}
			break;

		case DB_DOUBLE:
			switch (fld_type) {
				case DB_INTEGER:
					*((double *) data) = lvalue;
					break;
				case DB_DOUBLE:
					*((double *) data) = dvalue;
					break;
				case DB_STRING:
					if (svalue [0] < '0' || svalue [0] > '9' || svalue.find_first_of ("@:") != svalue.npos) {
						*((double *) data) = (int) Dtime (svalue);
					} else {
						*((double *) data) = svalue.Double ();
					}
					break;
				case DB_TIME:
					*((double *) data) = (double) tvalue;
					break;
				default:
					return (Status (DB_ERROR));
			}
			break;

		case DB_STRING:
			switch (fld->Type ()) {
				case DB_TIME:
					svalue = tvalue.Time_String ();
					break;
				default:
					if (fld_type == DB_INTEGER) {
						svalue (lvalue);
					} else if (fld_type == DB_DOUBLE) {
						svalue (dvalue, fld->Decimal ());
					}
					break;
			}
			len = (int) svalue.size ();
			if (len > 0) {
				if (len > fld->Width ()) len = fld->Width ();

				*((string *) data) = svalue.substr (0, len);
			} else {
				(*((string *) data)).clear ();
			}
			break;

		case DB_TIME:
			switch (fld_type) {
				case DB_INTEGER:
					*((Dtime *) data) = Dtime (lvalue, fld->Units ());
					break;
				case DB_DOUBLE:
					*((Dtime *) data) = Dtime (dvalue, fld->Units ());
					break;
				case DB_STRING:
					*((Dtime *) data) = svalue;
					break;
				case DB_TIME:
					*((Dtime *) data) = tvalue;
					break;
				default:
					return (Status (DB_ERROR));
			}
			break;
		default:
			return (Status (DB_ERROR));
	}
	return (true);
}
Exemple #5
0
void ExportNet::New_Links (void)
{
	int i, node, link, new_link, count, length, index, park_len, speed, time, dir;
	double offset, len, factor;

	Int_Map_Itr map_itr;
	Link_Data link_data, link_rec;
	Split_Itr split_itr, split2_itr;
	Link_Split_Itr link_itr;
	Points points;
	Dir_Data dir_ab, dir_ba, dir_rec;
	Shape_Data shape_rec;
	Points_Itr pt_itr;
	XYZ xyz;
	
	park_len = Round (Internal_Units (20, METERS)); 
	speed = Round (Internal_Units (5, MPS));
	time = Round (Internal_Units (20/5, SECONDS));

	map_itr = --link_map.end ();
	link = map_itr->first;
	new_link = ((link + 1) / 100 + 1) * 100;
	count = 0;

	//---- split links ----

	Set_Progress ();

	for (link=0, link_itr = link_splits.begin (); link_itr != link_splits.end (); link_itr++, link++) {
		if (link_itr->size () == 0) continue;
		Show_Progress ();

		link_data = link_array [link];

		if (link_data.AB_Dir () >= 0) {
			dir_ab = dir_array [link_data.AB_Dir ()];
		}
		if (link_data.BA_Dir () >= 0) {
			dir_ba = dir_array [link_data.BA_Dir ()];
		}
		offset = 0.0;

		for (split_itr = split2_itr = link_itr->begin (); split_itr != link_itr->end (); split2_itr = split_itr++) {
			link_rec = link_data;
			link_rec.Name (link_data.Name ());

			index = (int) link_array.size ();
			link_rec.Divided (3);

			split_itr->link = index;
			link_rec.Link (new_link++);

			if ((split_itr + 1) != link_itr->end ()) {
				link_rec.Bnode (split_itr->node);
				length = split_itr->offset;
				link_rec.Boffset (0);
			} else {
				length = link_rec.Length ();
			}
			if (split_itr != split2_itr) {
				link_rec.Anode (split2_itr->node);
				length -= split2_itr->offset;
				link_rec.Aoffset (0);
				offset = UnRound (split2_itr->offset);
			}
			len = UnRound (length);
			link_rec.Length (length);
			factor = (double) length / link_data.Length ();

			//---- split the link shape ----

			if (link_data.Shape () >= 0) {
				Link_Shape (&link_data, 0, points, offset, len);

				if (points.size () > 2) {
					shape_rec.Clear ();
					shape_rec.Link (link_rec.Link ());

					for (pt_itr = points.begin () + 1; pt_itr != points.end (); pt_itr++) {
						xyz.x = Round (pt_itr->x);
						xyz.y = Round (pt_itr->y);
						xyz.z = Round (pt_itr->z);

						shape_rec.push_back (xyz);
					}
					link_rec.Shape ((int) shape_array.size ());
					shape_map.insert (Int_Map_Data (shape_rec.Link (), link_rec.Shape ()));
					shape_array.push_back (shape_rec);
				} else {
					link_rec.Shape (-1);
				}
			}

			//---- process each direction ----

			if (link_data.AB_Dir () >= 0) {
				dir_rec = dir_ab;
				dir_rec.Link (index);
				dir_rec.First_Connect_From (-1);
				dir_rec.First_Connect_To (-1);

				if ((split_itr + 1) != link_itr->end ()) {
					dir_rec.First_Pocket (-1);
				}
				dir_rec.Time0 ((int) (dir_rec.Time0 () * factor + 0.5));

				dir = (int) dir_array.size ();
				link_rec.AB_Dir (dir);

				dir_map.insert (Int_Map_Data (dir_rec.Link_Dir (), dir));
				dir_array.push_back (dir_rec);
			} else {
				link_rec.AB_Dir (-1);
			}

			if (link_data.BA_Dir () >= 0) {
				dir_rec = dir_ba;
				dir_rec.Link (index);
				dir_rec.First_Connect_From (-1);
				dir_rec.First_Connect_To (-1);
			
				if (split_itr != split2_itr) {
					dir_rec.First_Pocket (-1);
				}
				dir_rec.Time0 ((int) (dir_rec.Time0 () * factor + 0.5));
				
				dir = (int) dir_array.size ();
				link_rec.BA_Dir (dir);

				dir_map.insert (Int_Map_Data (dir_rec.Link_Dir (), dir));
				dir_array.push_back (dir_rec);
			} else {
				link_rec.BA_Dir (-1);
			}

			//---- insert the link ----

			link_map.insert (Int_Map_Data (link_rec.Link (), index));
			link_array.push_back (link_rec);
			count++;
		}
	}

	//---- add parking connection links ----

	Set_Progress ();

	for (link=0, link_itr = link_splits.begin (); link_itr != link_splits.end (); link_itr++, link++) {
		if (link_itr->size () == 0) continue;
		Show_Progress ();

		for (split_itr = split2_itr = link_itr->begin (); split_itr != link_itr->end (); split2_itr = split_itr++) {

			for (i=0; i < 2; i++) {
				index = (int) link_array.size ();

				if (i == 0) {
					node = split_itr->park_ab;
					if (node < 0) continue;
					split_itr->link_ab = index;
				} else {
					node = split_itr->park_ba;
					if (node < 0) continue;
					split_itr->link_ba = index;
				}
				link_rec.Clear ();
				link_rec.Divided (3);

				link_rec.Link (new_link++);
				link_rec.Anode (split_itr->node);
				link_rec.Bnode (node);
				link_rec.Length (park_len);
				link_rec.Use (ANY);
				link_rec.Type (LOCAL);
				link_rec.Name ("Parking");
				
				//---- insert directional data ----

				dir_rec.Clear ();
				dir_rec.Link (index);
				dir_rec.Dir (0);
				dir_rec.Lanes (1);
				dir_rec.Speed (speed);
				dir_rec.Capacity (300);
				dir_rec.Time0 (time);
				dir_rec.Sign (YIELD_SIGN);

				dir = (int) dir_array.size ();
				link_rec.AB_Dir (dir);

				dir_map.insert (Int_Map_Data (dir_rec.Link_Dir (), dir));
				dir_array.push_back (dir_rec);

				dir_rec.Dir (1);
				dir_rec.Sign (NO_CONTROL);
			
				dir = (int) dir_array.size ();
				link_rec.BA_Dir (dir);

				dir_map.insert (Int_Map_Data (dir_rec.Link_Dir (), dir));
				dir_array.push_back (dir_rec);

				//---- insert the link ----

				link_map.insert (Int_Map_Data (link_rec.Link (), index));
				link_array.push_back (link_rec);
				count++;
			}
		}
	}
	Print (2, "Number of New Link Records = ") << count;
}
Exemple #6
0
void RoutePrep::Transfer_Link (void)
{
	int link_index, dir_index, length, best_len, best;
	double dx, dy, speed;

	Ints_Itr st1_itr, st2_itr;
	Int_Itr a_itr, b_itr;
	Node_Data *a_ptr, *b_ptr;
	Link_Data link_rec;
	Dir_Data dir_rec;

	if (station_nodes.size () < 2) return;

	link_rec.Use (Use_Code ("WALK"));
	link_rec.Type (WALKWAY);
	link_rec.Divided (1);

	link_rec.Name ("Transfer Link");

	dir_rec.Lanes (1);
	dir_rec.Speed (Internal_Units (3.0, MPH));
	dir_rec.Capacity (1000);
	speed = UnRound (dir_rec.Speed ());

	for (st1_itr = station_nodes.begin (); st1_itr != station_nodes.end (); st1_itr++) {
		st2_itr = st1_itr + 1;
		if (st2_itr == station_nodes.end ()) break;

		for (a_itr = st1_itr->begin (); a_itr != st1_itr->end (); a_itr++) {
			a_ptr = &node_array [*a_itr];

			best = -1; 
			best_len = MAX_INTEGER;

			for (b_itr = st2_itr->begin (); b_itr != st2_itr->end (); b_itr++) {
				b_ptr = &node_array [*b_itr];

				dx = a_ptr->X () - b_ptr->X ();
				dy = a_ptr->Y () - b_ptr->Y ();

				length = DTOI (sqrt (dx * dx + dy * dy));

				if (length < best_len) {
					best = *b_itr;
					best_len = length;
				}
			}
			if (best < 0) continue;

			link_index = (int) link_array.size ();
			dir_index = (int) dir_array.size ();
	
			link_rec.Anode (*a_itr);
			link_rec.Bnode (best);
			link_rec.Length (best_len);
			dir_rec.Time0 (UnRound (best_len) / speed);

			link_rec.AB_Dir (dir_index);

			dir_rec.Link (link_index);
			dir_map.insert (Int_Map_Data (dir_rec.Link_Dir (), dir_index));
			dir_array.push_back (dir_rec);

			link_rec.BA_Dir (++dir_index);

			dir_rec.Dir (1);

			dir_map.insert (Int_Map_Data (dir_rec.Link_Dir (), dir_index));
			dir_array.push_back (dir_rec);

			link_rec.Link (new_link++);
			link_map.insert (Int_Map_Data (link_rec.Link (), link_index));
			link_array.push_back (link_rec);
		}
	}
}