Exemplo n.º 1
0
bool ArcNet::Location_Processing (Db_File *fh)
{
	int link, dir;
	double offset;

	XYZ_Point *pt_ptr;
	Offset_Data offset_rec;
	Link_Data *link_ptr;
	Location_Data *location_ptr;

	Location_File *file = (Location_File *) fh;

	if (First_Record ()) {
		arcview_location.Num_Points (1);

		if (!location_offset.Max_Records (file->Num_Records ())) {
			Error ("Insufficient Memory for Location Points");
		}
	}

	if (Network_Service::Location_Processing (file)) {
		arcview_location.Copy_Fields (file);

		location_ptr = location_data.New_Record ();

		link = location_ptr->Link ();
		dir = location_ptr->Dir ();
		offset = UnRound (location_ptr->Offset ());		

		link_ptr = link_data.Get (link);

		Link_Shape (link_ptr, dir, &points, offset, 0.0, location_side);

		pt_ptr = points [1];

		arcview_location.points.Set (1, pt_ptr);

		if (!arcview_location.Write_Record ()) {
			Error ("Writing ArcView Activity Location File");
		}

		//---- save the location offset data ----

		offset_rec.ID (location_ptr->ID ());
		offset_rec.Link (link);
		offset_rec.Dir (dir);
		offset_rec.Offset (offset);
		offset_rec.X (pt_ptr->x);
		offset_rec.Y (pt_ptr->y);
		offset_rec.Z (pt_ptr->z);

		if (!location_offset.Add (&offset_rec)) {
			Error ("Saving Activity Location Offsets");
		}
	}
	return (false);
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
void Data_Service::Initialize_Locations (Location_File &file)
{
	Required_File_Check (file, LINK);
	
	int percent = System_Data_Reserve (LOCATION);

	if (location_array.capacity () == 0 && percent > 0) {
		int num = file.Num_Records ();

		if (percent != 100) {
			num = (int) ((double) num * percent / 100.0);
		}
		if (num > 1) {
			location_array.reserve (num);
			if (num > (int) location_array.capacity ()) Mem_Error (file.File_ID ());
		}
	}
}