예제 #1
0
        public static void SumTotals(this ZoneTotals zoneTotals, Parcel parcel)
        {
            if (zoneTotals == null)
            {
                throw new ArgumentNullException("zoneTotals");
            }

            if (parcel == null)
            {
                throw new ArgumentNullException("parcel");
            }

            zoneTotals.ThousandsSquareLengthUnits += parcel.ThousandsSquareLengthUnits;
            zoneTotals.EmploymentEducation        += parcel.EmploymentEducation;
            zoneTotals.EmploymentFood             += parcel.EmploymentFood;
            zoneTotals.EmploymentGovernment       += parcel.EmploymentGovernment;
            zoneTotals.EmploymentOffice           += parcel.EmploymentOffice;
            zoneTotals.EmploymentRetail           += parcel.EmploymentRetail;
            zoneTotals.EmploymentService          += parcel.EmploymentService;
            zoneTotals.EmploymentMedical          += parcel.EmploymentMedical;
            zoneTotals.EmploymentIndustrial       += parcel.EmploymentIndustrial;
            zoneTotals.EmploymentTotal            += parcel.EmploymentTotal;
            zoneTotals.Households         += parcel.Households;
            zoneTotals.StudentsUniversity += parcel.StudentsUniversity;
            zoneTotals.ParkingOffStreetPaidDailySpaces += parcel.ParkingOffStreetPaidDailySpaces;
            zoneTotals.StudentsK8         += parcel.StudentsK8;
            zoneTotals.StudentsHighSchool += parcel.StudentsHighSchool;
            zoneTotals.StudentsK12        += (parcel.StudentsK8 + parcel.StudentsHighSchool);
        }
예제 #2
0
        public static double GetStudentsUniversityDensity(this ZoneTotals zoneTotals, double squareLengthUnits)
        {
            if (zoneTotals == null)
            {
                throw new ArgumentNullException("zoneTotals");
            }

            return(Math.Log(1 + zoneTotals.StudentsUniversity * 100 / squareLengthUnits));
        }
예제 #3
0
        public static double GetHouseholdsDensity(this ZoneTotals zoneTotals, double squareLengthUnits)
        {
            if (zoneTotals == null)
            {
                throw new ArgumentNullException("zoneTotals");
            }

            return(Math.Log(1 + zoneTotals.Households * 100 / squareLengthUnits));
        }
예제 #4
0
        public static double GetEmploymentMedicalDensity(this ZoneTotals zoneTotals, double squareLengthUnits)
        {
            if (zoneTotals == null)
            {
                throw new ArgumentNullException("zoneTotals");
            }

            return(Math.Log(1 + zoneTotals.EmploymentMedical * 100 / squareLengthUnits));
        }
예제 #5
0
        public static double MillionsSquareLengthUnits(this ZoneTotals zoneTotals)
        {
            if (zoneTotals == null)
            {
                throw new ArgumentNullException("zoneTotals");
            }

            return(zoneTotals.ThousandsSquareLengthUnits / 1000 + .0001);
        }
예제 #6
0
파일: SubzoneTest.cs 프로젝트: sfcta/DaySim
        public void TestZoneTotals()
        {
            double thousandsSquareLengthUnits = 1.01;
            double employmentEducation        = 2.01;
            double employmentFood             = 3.01;
            double employmentGovernment       = 4.01;
            double employmentOffice           = 5.01;
            double employmentRetail           = 6.01;
            double employmentService          = 7.01;
            double employmentMedical          = 8.01;
            double employmentIndustrial       = 9.01;
            double employmentTotal            = 10.01;
            double households         = 11.01;
            double studentsUniversity = 12.01;
            double parkingOffStreetPaidDailySpaces = 13.01;
            double studentsK8         = 14.01;
            double studentsHighSchool = 15.01;
            double studentsK12        = 16.01;

            ZoneTotals totals = new ZoneTotals()
            {
                EmploymentEducation             = employmentEducation,
                EmploymentFood                  = employmentFood,
                EmploymentGovernment            = employmentGovernment,
                EmploymentIndustrial            = employmentIndustrial,
                EmploymentMedical               = employmentMedical,
                EmploymentOffice                = employmentOffice,
                EmploymentRetail                = employmentRetail,
                EmploymentService               = employmentService,
                EmploymentTotal                 = employmentTotal,
                Households                      = households,
                ParkingOffStreetPaidDailySpaces = parkingOffStreetPaidDailySpaces,
                StudentsHighSchool              = studentsHighSchool,
                StudentsK12                     = studentsK12,
                StudentsK8                      = studentsK8,
                StudentsUniversity              = studentsUniversity,
                ThousandsSquareLengthUnits      = thousandsSquareLengthUnits,
            };

            Assert.Equal(employmentEducation, totals.EmploymentEducation);
            Assert.Equal(employmentFood, totals.EmploymentFood);
            Assert.Equal(employmentGovernment, totals.EmploymentGovernment);
            Assert.Equal(employmentIndustrial, totals.EmploymentIndustrial);
            Assert.Equal(employmentMedical, totals.EmploymentMedical);
            Assert.Equal(employmentOffice, totals.EmploymentOffice);
            Assert.Equal(employmentRetail, totals.EmploymentRetail);
            Assert.Equal(employmentService, totals.EmploymentService);
            Assert.Equal(employmentTotal, totals.EmploymentTotal);
            Assert.Equal(households, totals.Households);
            Assert.Equal(parkingOffStreetPaidDailySpaces, totals.ParkingOffStreetPaidDailySpaces);
            Assert.Equal(studentsHighSchool, totals.StudentsHighSchool);
            Assert.Equal(studentsK12, totals.StudentsK12);
            Assert.Equal(studentsK8, totals.StudentsK8);
            Assert.Equal(studentsUniversity, totals.StudentsUniversity);
        }
예제 #7
0
파일: SubzoneTest.cs 프로젝트: sfcta/DaySim
        public void TestZoneTotalsExtensions()
        {
            double thousandsSquareLengthUnits = 1.01;
            double employmentEducation        = 2.01;
            double employmentFood             = 3.01;
            double employmentGovernment       = 4.01;
            double employmentOffice           = 5.01;
            double employmentRetail           = 6.01;
            double employmentService          = 7.01;
            double employmentMedical          = 8.01;
            double employmentIndustrial       = 9.01;
            double employmentTotal            = 10.01;
            double households         = 11.01;
            double studentsUniversity = 12.01;
            double parkingOffStreetPaidDailySpaces = 13.01;
            double studentsK8         = 14.01;
            double studentsHighSchool = 15.01;
            double studentsK12        = 16.01;

            ZoneTotals totals = new ZoneTotals()
            {
                EmploymentEducation             = employmentEducation,
                EmploymentFood                  = employmentFood,
                EmploymentGovernment            = employmentGovernment,
                EmploymentIndustrial            = employmentIndustrial,
                EmploymentMedical               = employmentMedical,
                EmploymentOffice                = employmentOffice,
                EmploymentRetail                = employmentRetail,
                EmploymentService               = employmentService,
                EmploymentTotal                 = employmentTotal,
                Households                      = households,
                ParkingOffStreetPaidDailySpaces = parkingOffStreetPaidDailySpaces,
                StudentsHighSchool              = studentsHighSchool,
                StudentsK12                     = studentsK12,
                StudentsK8                      = studentsK8,
                StudentsUniversity              = studentsUniversity,
                ThousandsSquareLengthUnits      = thousandsSquareLengthUnits,
            };

            double squareLengthUnits = 100;
            double density           = Math.Log(1 + employmentEducation * 100 / squareLengthUnits);

            Assert.Equal(density, totals.GetEmploymentEducationDensity(squareLengthUnits));

            density = Math.Log(1 + employmentGovernment * 100 / squareLengthUnits);
            Assert.Equal(density, totals.GetEmploymentGovernmentDensity(squareLengthUnits));

            density = Math.Log(1 + employmentMedical * 100 / squareLengthUnits);
            Assert.Equal(density, totals.GetEmploymentMedicalDensity(squareLengthUnits));

            density = Math.Log(1 + employmentOffice * 100 / squareLengthUnits);
            Assert.Equal(density, totals.GetEmploymentOfficeDensity(squareLengthUnits));

            density = Math.Log(1 + employmentRetail * 100 / squareLengthUnits);
            Assert.Equal(density, totals.GetEmploymentRetailDensity(squareLengthUnits));

            density = Math.Log(1 + employmentService * 100 / squareLengthUnits);
            Assert.Equal(density, totals.GetEmploymentServiceDensity(squareLengthUnits));

            density = Math.Log(1 + households * 100 / squareLengthUnits);
            Assert.Equal(density, totals.GetHouseholdsDensity(squareLengthUnits));

            density = Math.Log(1 + studentsK12 * 100 / squareLengthUnits);
            Assert.Equal(density, totals.GetStudentsK12Density(squareLengthUnits));

            density = Math.Log(1 + studentsUniversity * 100 / squareLengthUnits);
            Assert.Equal(density, totals.GetStudentsUniversityDensity(squareLengthUnits));

            density = thousandsSquareLengthUnits / 1000 + .0001;
            Assert.Equal(density, totals.MillionsSquareLengthUnits());

            Parcel parcel = new Parcel
            {
                EmploymentEducation        = employmentEducation,
                EmploymentFood             = employmentFood,
                EmploymentGovernment       = employmentGovernment,
                EmploymentIndustrial       = employmentIndustrial,
                EmploymentMedical          = employmentMedical,
                EmploymentOffice           = employmentOffice,
                EmploymentRetail           = employmentRetail,
                EmploymentService          = employmentService,
                EmploymentTotal            = employmentTotal,
                ThousandsSquareLengthUnits = thousandsSquareLengthUnits,
                Households = households,
                ParkingOffStreetPaidDailySpaces = parkingOffStreetPaidDailySpaces,
                StudentsK8         = studentsK8,
                StudentsHighSchool = studentsHighSchool,
                StudentsUniversity = studentsUniversity,
            };

            totals = new ZoneTotals();
            totals.SumTotals(parcel);
            Assert.Equal(employmentEducation, totals.EmploymentEducation);
            Assert.Equal(employmentFood, totals.EmploymentFood);
            Assert.Equal(employmentGovernment, totals.EmploymentGovernment);
            Assert.Equal(employmentIndustrial, totals.EmploymentIndustrial);
            Assert.Equal(employmentMedical, totals.EmploymentMedical);
            Assert.Equal(employmentOffice, totals.EmploymentOffice);
            Assert.Equal(employmentRetail, totals.EmploymentRetail);
            Assert.Equal(employmentService, totals.EmploymentService);
            Assert.Equal(employmentTotal, totals.EmploymentTotal);
            Assert.Equal(households, totals.Households);
            Assert.Equal(parkingOffStreetPaidDailySpaces, totals.ParkingOffStreetPaidDailySpaces);
            Assert.Equal(studentsHighSchool, totals.StudentsHighSchool);
            Assert.Equal(studentsK8 + studentsHighSchool, totals.StudentsK12);
            Assert.Equal(studentsK8, totals.StudentsK8);
            Assert.Equal(studentsUniversity, totals.StudentsUniversity);

            totals.SumTotals(parcel);
            Assert.Equal(2 * employmentEducation, totals.EmploymentEducation);
            Assert.Equal(2 * employmentFood, totals.EmploymentFood);
            Assert.Equal(2 * employmentGovernment, totals.EmploymentGovernment);
            Assert.Equal(2 * employmentIndustrial, totals.EmploymentIndustrial);
            Assert.Equal(2 * employmentMedical, totals.EmploymentMedical);
            Assert.Equal(2 * employmentOffice, totals.EmploymentOffice);
            Assert.Equal(2 * employmentRetail, totals.EmploymentRetail);
            Assert.Equal(2 * employmentService, totals.EmploymentService);
            Assert.Equal(2 * employmentTotal, totals.EmploymentTotal);
            Assert.Equal(2 * households, totals.Households);
            Assert.Equal(2 * parkingOffStreetPaidDailySpaces, totals.ParkingOffStreetPaidDailySpaces);
            Assert.Equal(2 * studentsHighSchool, totals.StudentsHighSchool);
            Assert.Equal(2 * (studentsHighSchool + studentsK8), totals.StudentsK12);
            Assert.Equal(2 * studentsK8, totals.StudentsK8);
            Assert.Equal(2 * studentsUniversity, totals.StudentsUniversity);
        }