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); }
bool TransitNet::Location_Processing (Db_File *fh) { int zone; if (Network_Service::Location_Processing (fh)) { Location_File *file = (Location_File *) fh; int id = file->Location (); if (id > max_location) max_location = id; zone = file->Zone (); if (zone > 0) { Location_Data *location_ptr = location_data.New_Record (); Dir_Path_Data *dir_ptr = dir_data.Get (location_ptr->Link_Dir ()); if (dir_ptr != NULL) { dir_ptr->Zone (zone); } } Location_File *new_file = (Location_File *) Network_Db_Base (NEW_ACTIVITY_LOCATION); new_file->Copy_Fields (file); if (!new_file->Write ()) { Error ("Writing %s", new_file->File_Type ()); } nlocation++; return (true); } return (false); }
bool SubareaNet::Location_Processing (Db_File *fh) { static Location_File *new_file; int id; Location_Data *location_ptr; Link_Data *link_ptr; Location_File *file = (Location_File *) fh; if (First_Record ()) { new_file = (Location_File *) Network_Db_Base (NEW_ACTIVITY_LOCATION); if (!location_data.Max_Records (file->Num_Records ())) goto mem_error; } id = file->Location (); if (id == 0) return (false); location_ptr = location_data.New_Record (); if (location_ptr == NULL) goto mem_error; location_ptr->ID (id); if (id > max_location) max_location = id; id = file->Zone (); if (id > max_zone) max_zone = id; link_ptr = link_data.Get (file->Link ()); if (link_ptr != NULL && link_ptr->Type () > 0) { //---- copy the fields to the subarea file ---- new_file->Copy_Fields (file); if (!new_file->Write ()) { Error ("Writing %s", new_file->File_Type ()); } nlocation++; return (true); } return (false); mem_error: Error ("Insufficient Memory for Activity Location Data"); return (false); }
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); }
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); }