Example #1
0
bool SubareaNet::Get_Location_Data (Location_File &file, Location_Data &data)
{
	//---- find the highest ID ----

	int id = file.Location ();
	if (id > max_location) max_location = id;

	id = file.Zone ();
	if (id > max_zone) max_zone = id;

	//---- do standard processing ----

	if (Data_Service::Get_Location_Data (file, data)) {

		//---- check the subarea boundary ----

		Link_Data *link_ptr = &link_array [data.Link ()];

		if (link_ptr->Type () == 0)  return (false);

		//---- copy the fields to the subarea file ----

		Db_Header *new_file = System_File_Header (NEW_LOCATION);

		new_file->Copy_Fields (file);

		if (!new_file->Write ()) {
			Error (String ("Writing %s") % new_file->File_Type ());
		}
		nlocation++;
		return (true);
	}
	return (false);
}
Example #2
0
bool ArcPlan::Get_Location_Data (Location_File &file, Location_Data &location_rec)
{
	int link, dir, index;
	double offset, setback, side;

	Point_Map_Stat map_stat;
	Link_Data *link_ptr;

	if (Data_Service::Get_Location_Data (file, location_rec)) {
		link = location_rec.Link ();
		dir = location_rec.Dir ();
		offset = UnRound (location_rec.Offset ());

		setback = UnRound (location_rec.Setback ());
		side = location_side;

		if (setback > side) side = setback;

		link_ptr = &link_array [link];

		if (lanes_flag) {
			bool dir_flag;
			int center, num_lanes;
			Dir_Data *dir_ptr;

			if (dir == 0) {
				index = link_ptr->AB_Dir ();
				dir_flag = (link_ptr->BA_Dir () >= 0);
			} else {
				index = link_ptr->BA_Dir ();
				dir_flag = (link_ptr->AB_Dir () >= 0);
			}
			if (index >= 0) {
				dir_ptr = &dir_array [index];
				num_lanes = dir_ptr->Lanes () + dir_ptr->Left () + dir_ptr->Right ();
			} else {
				num_lanes = 0;
			}
			if (center_flag && !dir_flag) {
				center = num_lanes + 1;
			} else {
				center = 1;
			}
			side += (2 * num_lanes - center) * lane_width / 2.0;
		}
		Link_Shape (link_ptr, dir, points, offset, 0.0, side);

		//---- save the location point data ----

		map_stat = location_pt.insert (Point_Map_Data (location_rec.Location (), points [0]));

		if (!map_stat.second) {
			Warning ("Duplicate Location Record = ") << location_rec.Location ();
		}
		return (true);
	}
	return (false);
}
Example #3
0
bool Data_Service::Get_Location_Data (Location_File &file, Location_Data &location_rec)
{
	int link, dir, offset;
	double setback;
	Link_Data *link_ptr;

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

	location_rec.Location (file.Location ());

	if (location_rec.Location () == 0) return (false);

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

	link_ptr = Set_Link_Direction (file, link, dir, offset);

	location_rec.Link (link);
	location_rec.Dir (dir);
	location_rec.Offset (offset);

	setback = file.Setback ();
	location_rec.Setback (setback);

	if (Location_XY_Flag ()) {
		Points points;

		Link_Shape (link_ptr, dir, points, UnRound (offset), 0.0, setback);

		if (points.size () > 0) {
			location_rec.X (points [0].x);
			location_rec.Y (points [0].y);
		} else {
			Node_Data *node_ptr = &node_array [link_ptr->Anode ()];
		
			location_rec.X (node_ptr->X ());
			location_rec.Y (node_ptr->Y ());
		}
	}
	location_rec.Zone (file.Zone ());

	if (location_rec.Zone () > 0 && System_Data_Flag (ZONE)) {
		Int_Map_Itr map_itr = zone_map.find (location_rec.Zone ());
		if (map_itr == zone_map.end ()) {
			Warning (String ("Location %d Zone %d was Not Found") % location_rec.Location () % location_rec.Zone ());
			return (false);
		}
		location_rec.Zone (map_itr->second);
	} else if (location_rec.Zone () == 0) {
		location_rec.Zone (-1);

		//---- delete extra activity location used for transit stops ----

		if (file.Version () <= 40) return (false);
	}
	location_rec.Notes (file.Notes ());

	return (true);
}
Example #4
0
bool LinkSum::Get_Location_Data (Location_File &file, Location_Data &data)
{
	int i, field, link, lvalue1, lvalue2, zone;
	double dvalue1, dvalue2;
	String buffer;

	Db_Field *fld;
	Link_Location loc_rec;
	Int_Itr int_itr;
	Int_Map_Itr map_itr;

	//---- get the link number ----

	link = file.Link ();
	if (link == 0) return (false);
	data.Link (link);

	//---- sum the activities on links ----

	if (activity_flag) {
		if (!link_db.Read_Record (link)) {
			Error (String ("Reading Link Database Record %d") % link);
		}

		//---- sum the data fields ----

		for (i=1, int_itr = field_list.begin (); int_itr != field_list.end (); int_itr++, i++) {
			field = *int_itr;

			fld = file.Field (field);

			if (fld->Type () == DB_INTEGER) {
				lvalue1 = file.Get_Integer (field);
				lvalue2 = link_db.Get_Integer (i);

				lvalue2 += lvalue1;
				link_db.Put_Field (i, lvalue2);
			} else if (fld->Type () == DB_DOUBLE) {
				dvalue1 = file.Get_Double (field);
				dvalue2 = link_db.Get_Double (i);

				dvalue2 += dvalue1;
				link_db.Put_Field (i, dvalue2);
			} else if (fld->Type () == DB_STRING) {
				link_db.Put_Field (i, file.Get_String (field));
			}
		}

		//---- save the changes ----

		if (!link_db.Write_Record (link)) {
			Error (String ("Writing Link Database Record %d") % link);
		}
	}

	//---- add a link location record ----

	if (zone_flag || group_flag) {
		zone = file.Zone ();

		if (zone > 0) {
			map_itr = link_map.find (link);
			if (map_itr == link_map.end ()) return (false);
			link = map_itr->second;

			loc_rec.link = link;
			loc_rec.location = i = file.Location ();
			loc_rec.zone = zone;
			loc_rec.count = 0;

			link_location.insert (Link_Loc_Map_Data (Int2_Key (link, i), loc_rec));
		}
	}

	//---- don't save the location data ----

	return (false);
}