Inheritance: ExtensibleDataObject
        private void MakeNewImages()
        {
            if (LimitPresenter == null)
            {
                return;
            }

            _calcImage = LimitPresenter.TmpCalcImage;
            _selectedTemperatureProfile = LimitPresenter.PreviewTemperatureProfile;
            _geographicLocation         = LimitPresenter.PreviewGeographicLocation;
            if (LimitPresenter.ThisTimeLimit.RootEntry == null)
            {
                throw new LPGException("root entry was null");
            }
            _rootEntry = LimitPresenter.ThisTimeLimit.RootEntry;
            _household = LimitPresenter.PreviewHousehold;
            TimeLimitPresenter p = null;

            if (Dispatcher == null || Thread.CurrentThread == Dispatcher.Thread)
            {
                p = LimitPresenter;
            }

            var t = new Thread(() => UpdatePictures(p));

            t.Start();
        }
Exemple #2
0
        public void TimeLimitLoadCreationAndSaveTest()
        {
            using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
            {
                db.ClearTable(GeographicLocation.TableName);
                db.ClearTable(GeographicLocHoliday.TableName);
                var holidays   = db.LoadHolidays();
                var geolocs    = new ObservableCollection <GeographicLocation>();
                var dbp        = db.LoadDateBasedProfiles();
                var timeLimits = db.LoadTimeLimits(dbp);
                GeographicLocation.LoadFromDatabase(geolocs, db.ConnectionString, holidays, timeLimits, false);
                (geolocs.Count).Should().Be(0);
                var geoloc = new GeographicLocation("bla", 1, 2, 3, 4, 5, 6, "North", "West",
                                                    db.ConnectionString, timeLimits[0], System.Guid.NewGuid().ToStrGuid());
                geoloc.SaveToDB();
                geoloc.AddHoliday(holidays[0]);
                GeographicLocation.LoadFromDatabase(geolocs, db.ConnectionString, holidays, timeLimits, false);
                (geolocs.Count).Should().Be(1);
                (geolocs[0].Holidays.Count).Should().Be(1);
                var gl = geolocs[0];
                ("bla").Should().Be(gl.Name);
                gl.DeleteFromDB();
                geolocs.Clear();
                GeographicLocation.LoadFromDatabase(geolocs, db.ConnectionString, holidays, timeLimits, false);
                (geolocs.Count).Should().Be(0);

                db.Cleanup();
            }
        }
Exemple #3
0
        private void getAllWaterSourceReports()
        {
            string jsonResponse     = GET(@"http://*****:*****@"Water Report #{report.id} <br /> {GetDescription(report.waterCondition)} {GetDescription(report.waterType)}";

                MarkerOptions option = new MarkerOptions()
                {
                    Animation = MarkerAnimation.Drop,
                    Clickable = true,
                    //Icon = Application.StartupPath + "\\about.png",
                    DraggingEnabled = false,
                };

                var marker = _gMapsWrapper.AddMarker(location, option, false);
                marker.Click       += new Action <IMarker, GeographicLocation>(my_marker_Click);
                marker.DoubleClick += new Action <IMarker, GeographicLocation>(marker_DoubleClick);
                marker.DragEnd     += new Action <IMarker, GeographicLocation>(marker_DragEnd);

                markers.Add(marker.MarkerId, messageToShow);
            }
        }
        public static MemoryStream CreerEvenementCalendrier(string objet, string description, string adresse, DateTime dateDebut, DateTime dateFin, double lattitude = 0, double longitude = 0)
        {
            GeographicLocation coordonneesGPS = null;

            if (lattitude != 0 && longitude != 0)
            {
                coordonneesGPS = new GeographicLocation(45.756386, 4.8379093);
            }
            Calendar      calendar = new Calendar();
            CalendarEvent myEvent  = new CalendarEvent
            {
                Start              = new CalDateTime(dateDebut),
                End                = new CalDateTime(dateFin),
                Summary            = objet,
                Description        = description,
                Location           = adresse,
                GeographicLocation = coordonneesGPS,
            };

            calendar.Events.Add(myEvent);
            MemoryStream       stream     = new MemoryStream();
            CalendarSerializer serializer = new CalendarSerializer();

            serializer.Serialize(calendar, stream, Encoding.ASCII);
            return(stream);
        }
Exemple #5
0
    public double Distance(GeographicLocation myLocation)
    {
        // This instance method calculates the distance from the current
        // instance location to another GeographicLocation specified by
        // a parameter that refers to the location.

        // DO NOT MODIFY THIS METHOD.

        double latitudeDD1  = myLocation.LatitudeRadians;
        double longitudeDD1 = myLocation.LongitudeRadians;
        double latitudeDD2  = LatitudeRadians;
        double longitudeDD2 = LongitudeRadians;

        double sinLambda = Math.Sin(longitudeDD1 - longitudeDD2);
        double cosLambda = Math.Cos(longitudeDD1 - longitudeDD2);

        double distance = NASA.Earth.EquatorialRadius * Math.Atan2(Math.Sqrt(
                                                                       Math.Cos(latitudeDD1) * sinLambda *
                                                                       Math.Cos(latitudeDD1) * sinLambda +
                                                                       (Math.Cos(latitudeDD2) * Math.Sin(latitudeDD1) -
                                                                        Math.Sin(latitudeDD2) * Math.Cos(latitudeDD1) *
                                                                        cosLambda) *
                                                                       (Math.Cos(latitudeDD2) * Math.Sin(latitudeDD1) -
                                                                        Math.Sin(latitudeDD2) * Math.Cos(latitudeDD1) *
                                                                        cosLambda)),
                                                                   (Math.Sin(latitudeDD2) * Math.Sin(latitudeDD1) +
                                                                    Math.Cos(latitudeDD2) * Math.Cos(latitudeDD1) *
                                                                    cosLambda));

        return(distance);
    }
Exemple #6
0
 /// <summary>
 ///     starter for real calcs
 /// </summary>
 public CalcStartParameterSet(
     [NotNull] Func <bool, string, ObservableCollection <ResultFileEntry>, bool>
     reportFinishFuncForHouseAndSettlement,
     [NotNull] Func <bool, string, string, bool> reportFinishFuncForHousehold,
     [NotNull] Func <object, bool> openTabFunc, [CanBeNull] ILPGDispatcher dispatcher,
     [NotNull] GeographicLocation geographicLocation,
     [NotNull] TemperatureProfile temperatureProfile,
     [NotNull] ICalcObject calcTarget,
     EnergyIntensityType energyIntensity, [NotNull] Func <bool> reportCancelFunc, bool resumeSettlement,
     [CanBeNull] DeviceSelection deviceSelection, LoadTypePriority loadTypePriority,
     [CanBeNull] TransportationDeviceSet transportationDeviceSet, [CanBeNull] TravelRouteSet travelRouteSet,
     [NotNull] List <CalcOption> calcOptions,
     DateTime officialSimulationStartTime,
     DateTime officialSimulationEndTime,
     TimeSpan internalTimeResolution,
     [NotNull] string csvCharacter,
     int selectedRandomSeed,
     TimeSpan externalTimeResolution, bool deleteDatFiles, bool writeExcelColumn, bool showSettlingPeriod,
     int settlingDays, int affordanceRepetitionCount, [NotNull] CalculationProfiler calculationProfiler,
     [CanBeNull] ChargingStationSet chargingStationSet,
     [CanBeNull][ItemNotNull] List <string> loadTypesToProcess,
     DeviceProfileHeaderMode deviceProfileHeaderMode,
     bool ignorePreviousActivitiesWhenNeeded, string resultPath, bool transportationEnabled)
 {
     IgnorePreviousActivitiesWhenNeeded = ignorePreviousActivitiesWhenNeeded;
     ResultPath                            = resultPath;
     LoadTypesToProcess                    = loadTypesToProcess;
     ExternalTimeResolution                = externalTimeResolution;
     DeleteDatFiles                        = deleteDatFiles;
     WriteExcelColumn                      = writeExcelColumn;
     ShowSettlingPeriod                    = showSettlingPeriod;
     SettlingDays                          = settlingDays;
     AffordanceRepetitionCount             = affordanceRepetitionCount;
     CalculationProfiler                   = calculationProfiler;
     SelectedRandomSeed                    = selectedRandomSeed;
     OfficialSimulationStartTime           = officialSimulationStartTime;
     OfficialSimulationEndTime             = officialSimulationEndTime;
     InternalTimeResolution                = internalTimeResolution;
     CsvCharacter                          = csvCharacter;
     ReportFinishFuncForHouseAndSettlement = reportFinishFuncForHouseAndSettlement;
     ReportFinishFuncForHousehold          = reportFinishFuncForHousehold;
     OpenTabFunc                           = openTabFunc;
     Dispatcher                            = dispatcher;
     GeographicLocation                    = geographicLocation;
     TemperatureProfile                    = temperatureProfile;
     CalcTarget                            = calcTarget;
     EnergyIntensity                       = energyIntensity;
     ReportCancelFunc                      = reportCancelFunc;
     ResumeSettlement                      = resumeSettlement;
     LPGVersion                            = Utili.GetCurrentAssemblyVersion();
     DeviceSelection                       = deviceSelection;
     LoadTypePriority                      = loadTypePriority;
     TransportationDeviceSet               = transportationDeviceSet;
     TravelRouteSet                        = travelRouteSet;
     CalcOptions                           = calcOptions;
     ChargingStationSet                    = chargingStationSet;
     DeviceProfileHeaderMode               = deviceProfileHeaderMode;
     CalculationStartTime                  = DateTime.Now;
     TransportationEnabled                 = transportationEnabled;
 }
        public async Task <Calendar> GenerateCalendar(Guid id)
        {
            var entity = await _schoolingEventRepository.GetById(id);

            if (entity == null)
            {
                await _bus.RaiseEvent(new DomainNotification("GenerateCalendar", $"Event with id {id} doesn't exist"));

                return(null);
            }

            var daysToPack         = entity.Schedule.ToList();
            var eventLocation      = entity.Location;
            var geographicLocation = new GeographicLocation(eventLocation.Lat, eventLocation.Lng);

            var calendarEvents = daysToPack.Select(d => new CalendarEvent
            {
                Start              = new CalDateTime(d.Start),
                End                = new CalDateTime(d.End),
                Description        = d.Description,
                Location           = eventLocation.Description,
                GeographicLocation = geographicLocation,
                Summary            = d.Title
            });

            var calendar = new Calendar();

            calendar.Events.AddRange(calendarEvents);

            return(calendar);
        }
Exemple #8
0
 public TrackPointGpx(GeographicLocation gc, Elevation ele, TimeMeasure t, bool gcValid = true, bool eleValid = true)
 {
     _geoCoord       = gc;
     _elevation      = ele;
     _time           = t;
     _geoCoordValid  = gcValid;
     _elevationValid = eleValid;
 }
        public void Should_Not_Throw_FormatException_When_Instantiated()
        {
            GeographicLocation location = new GeographicLocation();

            Action act = () => location.EarthCoordinate = new Coordinate(51.476852, -0.000500, new DateTime(2000, 1, 1));

            act.Should().NotThrow <FormatException>();
        }
        public TrackPointGpx ReadTrackPointGpx()
        {
            // Start by reading in the Track Point line (which will have the Lat and Lon on it)
            string currentString = _gpxLines.ElementAt <string>(_lineNumber);

            int startLat  = currentString.IndexOf("lat=") + 5;
            int startLong = currentString.IndexOf("lon=") + 5;;

            string latStr  = "";
            string longStr = "";

            int idx = startLat;

            while (currentString[idx] != '"')
            {
                latStr += currentString[idx]; ++idx;
            }

            idx = startLong;
            while (currentString[idx] != '"')
            {
                longStr += currentString[idx]; ++idx;
            }

            double             latitude  = Convert.ToDouble(latStr);
            double             longitude = Convert.ToDouble(longStr);
            GeographicLocation geo       = new GeographicLocation(latitude, longitude);

            // Now move forward and do the Elevation and Time lines
            // For now, will not worry about allowing the order to come in differently
            // Both Suunto and Garmin seem to send the data in this order
            // NOTE: Strava premium GPX downoads do not include time stamps!!
            ++_lineNumber;
            Elevation ele = ReadElevation();

            ++LineNumber;

            TimeMeasure tm        = new TimeMeasure();
            string      nextToken = IdentifyToken();

            if (nextToken == "time")
            {
                tm = ReadTimeMeasure();
                ++LineNumber;
            }

            // have read in the data we want
            // DCL To Do: Do I want to get the distance extension for the Suunto watches?
            nextToken = "";
            do
            {
                nextToken = IdentifyToken();
                ++_lineNumber;
            } while (nextToken != "/trkpt");


            return(new TrackPointGpx(geo, ele, tm));
        }
Exemple #11
0
        void UpdateLocationDot(GeographicLocation location)
        {
            double x = (location.Longitude + 180) * absLayout.Width / 360;
            double y = (90 - location.Latitude) * absLayout.Height / 180;

            AbsoluteLayout.SetLayoutBounds(ellipse,
                                           new Rectangle(x, y, AbsoluteLayout.AutoSize,
                                                         AbsoluteLayout.AutoSize));
        }
 private void my_marker_Click(IMarker arg1, GeographicLocation arg2)
 {
     var infoWindow = _gMapsWrapper.ShowInfoWindow(markers[arg1.MarkerId], arg1,
                                                   new InfoWindowOptions()
     {
         MaxWidth = 150, DisableAutoPan = false
     }, true);
     //infoWindow.CloseClick += new Action<IInfoWindow>(infoWindow_CloseClick);
 }
Exemple #13
0
        void OnLocationTrackerLocationChanged(object sender, GeographicLocation args)
        {
            locationLabel.Text  = args.ToString();
            timestampLabel.Text = DateTime.Now.ToString("h:mm:ss.FFF");

            // Update dot on map.
            location = args;
            UpdateLocationDot(args);
        }
        public void Should_Have_Valid_Elevation_Number_When_Instantiated()
        {
            GeographicLocation location  = new GeographicLocation();
            double             elevation = double.NaN;

            Action act = () => location.Elevation = elevation;

            act.Should().Throw <ArgumentException>()
            .WithMessage("*" + DeploySoftware_LaunchPad_Core_Resources.Guard_GeographicLocation_Set_Elevation + "*");
        }
        public void Should_Not_Allow_Latitude_Greater_Than_90()
        {
            GeographicLocation          location  = new GeographicLocation();
            double                      latitude  = 90.001;
            double                      longitude = 0.0;
            ArgumentOutOfRangeException ex        = Assert.Throws <ArgumentOutOfRangeException>(
                () => new GeographicLocation(latitude, longitude)
                );

            Assert.Contains(DeploySoftware_LaunchPad_Core_Resources.Guard_GeographicLocation_Set_Latitude_Not_GreaterThan_90, ex.Message);
        }
        private static GeographicLocation FindGeographicLocation([NotNull] Simulator sim, [NotNull] JsonCalcSpecification calcSpecification)
        {
            GeographicLocation geoloc = sim.GeographicLocations[0];

            if (calcSpecification.GeographicLocation != null)
            {
                geoloc = sim.GeographicLocations.FindByJsonReference(calcSpecification.GeographicLocation);
            }

            return(geoloc);
        }
        private void CmbGeographicLocationSelectionChanged([CanBeNull] object sender,
                                                           [CanBeNull] SelectionChangedEventArgs e)
        {
            if (CmbPreviewGeographicLocation.SelectedItem == null)
            {
                return;
            }

            _geographicLocation = (GeographicLocation)CmbPreviewGeographicLocation.SelectedItem;
            MakeNewImages();
        }
Exemple #18
0
 public SettlementTemplate([NotNull] string pName, [CanBeNull] int?id, [CanBeNull] string description, [NotNull] string connectionString,
                           int desiredHHCount, [NotNull] string newName, [CanBeNull] TemperatureProfile temperatureProfile,
                           [CanBeNull] GeographicLocation geographicLocation, StrGuid guid) : base(pName, TableName, connectionString, guid)
 {
     ID                  = id;
     _description        = description;
     TypeDescription     = "Settlement Template";
     _desiredHHCount     = desiredHHCount;
     _newName            = newName;
     _temperatureProfile = temperatureProfile;
     _geographicLocation = geographicLocation;
 }
Exemple #19
0
        // Location tracking and go-to location methods.
        void OnLocationTracker(object sender, GeographicLocation args)
        {
            userPosition = new Position(args.Latitude, args.Longitude);

            // Determine distances between the user and museums.
            foreach (Site site in locations.Sites)
            {
                Position sitePosition = new Position(site.Latitude, site.Longitude);
                site.DistanceToUser = sitePosition.DistanceTo(userPosition).Miles;
            }

            myLocationButton.IsVisible = Device.OS != TargetPlatform.Android;
        }
Exemple #20
0
 public House([NotNull] string pName, [CanBeNull] string description, [CanBeNull] TemperatureProfile temperatureProfile, [CanBeNull] GeographicLocation geographicLocation,
              [CanBeNull] HouseType houseType, [NotNull] string connectionString, EnergyIntensityType energyIntensity, [CanBeNull] string source, CreationType creationType,
              StrGuid guid, [CanBeNull] int?pID = null) : base(pName, TableName, connectionString, guid)
 {
     ID = pID;
     TypeDescription      = "House";
     _description         = description;
     _energyIntensityType = energyIntensity;
     _temperatureProfile  = temperatureProfile;
     _geographicLocation  = geographicLocation;
     _houseType           = houseType;
     _source       = source;
     _creationType = creationType;
 }
 public bool ItemExists([NotNull] ICalcObject mycalcObject, [NotNull] GeographicLocation geoloc,
                        [NotNull] TemperatureProfile temperatureProfile,
                        EnergyIntensityType intensity, [NotNull] string lpgVersion)
 {
     foreach (var co in MyItems)
     {
         if (co.HouseholdName == mycalcObject.Name && co.GeographicLocationName == geoloc.Name &&
             co.TemperatureProfile == temperatureProfile.Name && co.EnergyIntensity == intensity.ToString() &&
             co.LPGVersion == lpgVersion)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #22
0
        //public const string TableName = "CalcStartParameterSet";

        /// <summary>
        ///     starter for unit tests
        /// </summary>
        public CalcStartParameterSet(
            [NotNull] GeographicLocation geographicLocation,
            [NotNull] TemperatureProfile temperatureProfile,
            [NotNull] ICalcObject calcTarget,
            EnergyIntensityType energyIntensity,
            bool resumeSettlement,
            [CanBeNull] DeviceSelection deviceSelection,
            LoadTypePriority loadTypePriority,
            [CanBeNull] TransportationDeviceSet transportationDeviceSet, [CanBeNull] ChargingStationSet chargingStationSet,
            [CanBeNull] TravelRouteSet travelRouteSet, [NotNull] List <CalcOption> calcOptions,
            DateTime officialSimulationStartTime,
            DateTime officialSimulationEndTime,
            TimeSpan internalTimeResolution,
            [NotNull] string csvCharacter,
            int selectedRandomSeed,
            TimeSpan externalTimeResolution, bool deleteDatFiles, bool writeExcelColumn, bool showSettlingPeriod,
            int settlingDays, int affordanceRepetitionCount, [NotNull] CalculationProfiler calculationProfiler, string resultPath, bool transportationEnabled)
        {
            OfficialSimulationStartTime = officialSimulationStartTime;
            OfficialSimulationEndTime   = officialSimulationEndTime;
            InternalTimeResolution      = internalTimeResolution;
            CsvCharacter              = csvCharacter;
            SelectedRandomSeed        = selectedRandomSeed;
            ExternalTimeResolution    = externalTimeResolution;
            DeleteDatFiles            = deleteDatFiles;
            WriteExcelColumn          = writeExcelColumn;
            ShowSettlingPeriod        = showSettlingPeriod;
            SettlingDays              = settlingDays;
            AffordanceRepetitionCount = affordanceRepetitionCount;
            CalculationProfiler       = calculationProfiler;
            GeographicLocation        = geographicLocation;
            TemperatureProfile        = temperatureProfile;
            CalcTarget              = calcTarget;
            EnergyIntensity         = energyIntensity;
            ResumeSettlement        = resumeSettlement;
            LPGVersion              = Utili.GetCurrentAssemblyVersion();
            DeviceSelection         = deviceSelection;
            LoadTypePriority        = loadTypePriority;
            TransportationDeviceSet = transportationDeviceSet;
            TravelRouteSet          = travelRouteSet;
            CalcOptions             = calcOptions;
            ChargingStationSet      = chargingStationSet;
            DeviceProfileHeaderMode = DeviceProfileHeaderMode.Standard;
            ResultPath              = resultPath;
            CalculationStartTime    = DateTime.Now;
            TransportationEnabled   = transportationEnabled;
        }
Exemple #23
0
        public List <CalcAffordanceDto> SetCalcAffordances([NotNull][ItemNotNull] IEnumerable <CalcLocationDto> locs,
                                                           [NotNull] TemperatureProfile temperatureProfile,
                                                           [NotNull] CalcLoadTypeDtoDictionary ltdict,
                                                           [NotNull] GeographicLocation geographicLocation,
                                                           [NotNull] Random rnd,
                                                           int timeStepsPerHour, TimeSpan internalStepSize,
                                                           [NotNull][ItemNotNull] List <VacationTimeframe> vacationTimeframes, [NotNull] string holidayKey,
                                                           [NotNull][ItemNotNull] ObservableCollection <DeviceAction> deviceActions,
                                                           [NotNull] Dictionary <CalcLocationDto, List <AffordanceWithTimeLimit> > affordanceDict,
                                                           [NotNull] LocationDtoDict locDict,
                                                           [NotNull] out List <DateTime> bridgeDays,
                                                           [NotNull] HouseholdKey householdKey, [NotNull][ItemNotNull] List <CalcDeviceDto> allCalcDeviceDtos,
                                                           [ItemNotNull][NotNull] List <DeviceCategoryDto> deviceCategoryDtos)
        {
            List <CalcAffordanceDto> allCalcAffordances = new List <CalcAffordanceDto>();

            bridgeDays = new List <DateTime>();
            // get affordances
            foreach (var calcLocation in locs)
            {
                var affs = affordanceDict[calcLocation];
                var tmp  = affs.Distinct();
                if (affs.Count != tmp.Count())
                {
                    throw new LPGException("double affordances!?!");
                }

                var devicesAtLoc = allCalcDeviceDtos.Where(x => x.LocationGuid == calcLocation.Guid).ToList();
                var affordances  = GetCalcAffordancesAtLocation(calcLocation, affs, internalStepSize, timeStepsPerHour, temperatureProfile,
                                                                ltdict, geographicLocation, rnd, vacationTimeframes, holidayKey, deviceActions,
                                                                locDict,
                                                                out var tmpBridgeDays, householdKey, devicesAtLoc, deviceCategoryDtos);
                allCalcAffordances.AddRange(affordances);
                foreach (var tmpBridgeDay in tmpBridgeDays)
                {
                    if (!bridgeDays.Contains(tmpBridgeDay))
                    {
                        bridgeDays.Add(tmpBridgeDay);
                    }
                }

                //calcLocation.SortAffordances();
            }

            return(allCalcAffordances);
        }
Exemple #24
0
        public GeographicLocation[] getGeographicLocations(string zipcode)
        {
            if (String.IsNullOrEmpty(zipcode))
            {
                throw new ArgumentNullException("Must supply zipcode");
            }
            string       statement    = "SELECT * FROM ZIPCodes WHERE ZIPCode = @ZIPCODE;";
            SqlCommand   command      = new SqlCommand(statement);
            SqlParameter zipcodeParam = new SqlParameter("@ZIPCODE", SqlDbType.NVarChar, 5);

            zipcodeParam.Value = zipcode;
            command.Parameters.Add(zipcodeParam);

            DataTable results = query(command);

            if (results == null || results.Rows == null || results.Rows.Count == 0)
            {
                return(null);
            }

            GeographicLocation[] locations = new GeographicLocation[results.Rows.Count];
            for (int i = 0; i < results.Rows.Count; i++)
            {
                GeographicLocation loc = new GeographicLocation();
                loc.Zipcode           = zipcode;
                loc.ZipcodeType       = results.Rows[i][1] as string;
                loc.CityName          = results.Rows[i][2] as string;
                loc.CityType          = results.Rows[i][3] as string;
                loc.CountyName        = results.Rows[i][4] as string;
                loc.CountyFips        = results.Rows[i][5] as string;
                loc.StateName         = results.Rows[i][6] as string;
                loc.StateAbbreviation = results.Rows[i][7] as string;
                loc.StateFips         = results.Rows[i][8] as string;
                loc.MsaCode           = results.Rows[i][9] as string;
                loc.AreaCode          = results.Rows[i][10] as string;
                loc.TimeZone          = results.Rows[i][11] as string;
                loc.Utc             = getInt(results.Rows[i][12]);
                loc.DaylightSavings = ((results.Rows[i][13] as string) == "Y");
                loc.Latitude        = getDouble(results.Rows[i][14]);
                loc.Longitude       = getDouble(results.Rows[i][15]);
                locations[i]        = loc;
            }

            return(locations);
        }
Exemple #25
0
        private void MakeAffordanceTimelimit([NotNull] TemperatureProfile temperatureProfile,
                                             [NotNull] GeographicLocation geographicLocation,
                                             [NotNull] Random rnd, [NotNull][ItemNotNull] List <VacationTimeframe> vacationTimeframes,
                                             [NotNull] string holidayKey, [NotNull] List <DateTime> bridgeDays,
                                             AffordanceWithTimeLimit aff,
                                             [NotNull] out AvailabilityDataReferenceDto availabilityDataReference)
        {
            //time limit stuff
            if (aff.Affordance.TimeLimit == null)
            {
                throw new DataIntegrityException("The time limit on the affordance was null. Please fix",
                                                 aff.Affordance);
            }

            var tl = aff.Affordance.TimeLimit;

            if (aff.TimeLimit != null)
            {
                tl = aff.TimeLimit;
            }
            if (tl.RootEntry == null)
            {
                throw new LPGException("Root Entry was null");
            }

            var tmparr = tl.RootEntry.GetOneYearArray(
                _cp.InternalStepsize,
                _cp.InternalStartTime,
                _cp.InternalEndTime, temperatureProfile, geographicLocation, rnd,
                vacationTimeframes, holidayKey, out var tmpBridgeDays, aff.StartMinusTime, aff.StartPlusTime,
                aff.EndMinusTime,
                aff.EndPlusTime);

            foreach (var tmpBridgeDay in tmpBridgeDays)
            {
                if (!bridgeDays.Contains(tmpBridgeDay))
                {
                    bridgeDays.Add(tmpBridgeDay);
                }
            }

            // invertieren von erlaubten zu verbotenen zeiten
            tmparr = tmparr.Not();
            availabilityDataReference = _availabilityDtoRepository.MakeNewReference(tl.Name, tmparr);
        }
Exemple #26
0
        public void TimeLimitArrayTestDateProfileTest()
        {
            using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
            {
                db.ClearTable(TimeLimit.TableName);
                db.ClearTable(TimeLimitEntry.TableName);
                // test if night + day is always
                var dateBasedProfile = new DateBasedProfile("blub", "bla", db.ConnectionString, Guid.NewGuid().ToStrGuid());
                dateBasedProfile.SaveToDB();
                dateBasedProfile.AddNewDatePoint(new DateTime(2014, 1, 1), 100);
                dateBasedProfile.AddNewDatePoint(new DateTime(2014, 1, 3), 0);
                dateBasedProfile.SaveToDB();
                var start   = new DateTime(1900, 1, 1, 0, 0, 0);
                var end     = new DateTime(1900, 1, 1, 1, 1, 1);
                var dt      = new TimeLimit("blub", db.ConnectionString, Guid.NewGuid().ToStrGuid(), 1);
                var temp    = new TemperatureProfile("blub", 1, "bla", string.Empty, Guid.NewGuid().ToStrGuid());
                var enddate = new DateTime(1900, 1, 2, 0, 0, 0);
                temp.AddTemperature(start, 0, 1, true, false);
                temp.AddTemperature(enddate, 10, 1, true, false);
                var dateBasedProfiles = new ObservableCollection <DateBasedProfile>();
                dt.AddTimeLimitEntry(null, start, end, PermissionMode.ControlledByDateProfile, 1, 1, true, true, true, true,
                                     true, true, true, 1, 1, 1, 1, 1, 1, 1, true, false, AnyAllTimeLimitCondition.Any, start, end,
                                     dateBasedProfile.ID, 150, 50, false, false, true, false, 5, false, dateBasedProfiles, 0, 0, 0);
                dateBasedProfiles.Add(dateBasedProfile);
                var geoloc             = new GeographicLocation(db.ConnectionString, null, Guid.NewGuid().ToStrGuid());
                var r                  = new Random();
                var vacationTimeFrames = new List <VacationTimeframe>();
                var br                 = dt.TimeLimitEntries[0].GetOneYearHourArray(temp, geoloc, r, vacationTimeFrames, "test",
                                                                                    out _);

                for (var i = 0; i < br.Count; i++)
                {
                    if (i < 48)
                    {
                        (br[i]).Should().Be(true);
                    }
                    else
                    {
                        (br[i]).Should().Be(false);
                    }
                }
                db.Cleanup();
            }
        }
 public Radarsat1Observation(
     int?tenantId,
     string sceneId,
     string mdaOrderNumber,
     string geographicalArea,
     DateTime sceneStart,
     DateTime sceneStop,
     string orbit,
     string orbitDataType,
     string applicationLut,
     string beamMode,
     string productType,
     string format,
     int numberImageLines,
     int numberImagePixels,
     string pixelSpacing,
     GeographicLocation sceneCentre,
     ImageObservationCornerCoordinates cornerCoordinates
     ) : base()
 {
     Id = Guid.NewGuid();
     CurrentLocation                  = new SpaceTimeInformation();
     SceneId                          = sceneId;
     MdaOrderNumber                   = mdaOrderNumber;
     GeographicalArea                 = geographicalArea;
     SceneStartTime                   = sceneStart;
     SceneStopTime                    = sceneStop;
     Orbit                            = orbit;
     OrbitDataType                    = orbitDataType;
     ApplicationLut                   = applicationLut;
     BeamMode                         = beamMode;
     ProductType                      = productType;
     Format                           = format;
     NumberImageLines                 = numberImageLines;
     NumberImagePixels                = numberImagePixels;
     PixelSpacing                     = pixelSpacing;
     SceneCentre                      = sceneCentre;
     Corners                          = cornerCoordinates;
     CreationTime                     = Clock.Now;
     LastModificationTime             = Clock.Now;
     CurrentLocation.PhysicalLocation = SceneCentre;
     CurrentLocation.PointInTime      = SceneStartTime;
 }
 public GeographicLocationTO(GeographicLocation mdo)
 {
     this.zipcode           = mdo.Zipcode;
     this.zipcodeType       = mdo.ZipcodeType;
     this.cityName          = mdo.CityName;
     this.cityType          = mdo.CityType;
     this.countyName        = mdo.CountyName;
     this.countyFips        = mdo.CountyFips;
     this.stateName         = mdo.StateName;
     this.stateAbbreviation = mdo.StateAbbreviation;
     this.stateFips         = mdo.StateFips;
     this.msaCode           = mdo.MsaCode;
     this.areaCode          = mdo.AreaCode;
     this.timeZone          = mdo.TimeZone;
     this.utc             = mdo.Utc;
     this.daylightSavings = mdo.DaylightSavings;
     this.latitude        = mdo.Latitude;
     this.longitude       = mdo.Longitude;
 }
Exemple #29
0
        private void _gMapsWrapper_CenterChanged(GeographicLocation obj)
        {
            GeographicBounds limit = new GeographicBounds()
            {
                SouthWest = new GeographicLocation(-35.0418205762627, 16.3491015625),
                NorthEast = new GeographicLocation(-21.9971918060098, 33.0483203125)
            };

            if (cbLimitMap.Checked)
            {
                bool changed = false;
                if (obj.Latitude < limit.SouthWest.Latitude - 0.1)
                {
                    changed      = true;
                    obj.Latitude = limit.SouthWest.Latitude;
                }
                else if (obj.Latitude > limit.NorthEast.Latitude + 0.1)
                {
                    changed      = true;
                    obj.Latitude = limit.NorthEast.Latitude;
                }

                if (obj.Longitude < limit.SouthWest.Longitude - 0.1)
                {
                    changed       = true;
                    obj.Longitude = limit.SouthWest.Longitude;
                }
                else if (obj.Longitude > limit.NorthEast.Longitude + 0.1)
                {
                    changed       = true;
                    obj.Longitude = limit.NorthEast.Longitude;
                }

                if (changed)
                {
                    _gMapsWrapper.Center = obj;
                }
            }

            lblCenter.Text    = obj.ToString();
            lblLastEvent.Text = "Center_Changed";
        }
Exemple #30
0
 public Radarsat1Observation(
     TPrimaryKey id,
     int?tenantId,
     string sceneId,
     string mdaOrderNumber,
     string geographicalArea,
     DateTime sceneStart,
     DateTime sceneStop,
     string orbit,
     string orbitDataType,
     string applicationLut,
     string beamMode,
     string productType,
     string format,
     int numberImageLines,
     int numberImagePixels,
     string pixelSpacing,
     GeographicLocation sceneCentre,
     ImageObservationCornerCoordinates cornerCoordinates
     ) : base()
 {
     Id = id;
     new Radarsat1Observation <TPrimaryKey, TFileStorageLocationType>(
         tenantId,
         sceneId,
         mdaOrderNumber,
         geographicalArea,
         sceneStart,
         sceneStop,
         orbit,
         orbitDataType,
         applicationLut,
         beamMode,
         productType,
         format,
         numberImageLines,
         numberImagePixels,
         pixelSpacing,
         sceneCentre,
         cornerCoordinates
         );
 }
        public void CanSerializePrivateMembers()
        {
            GeographicLocation loc = new GeographicLocation();

            loc.Latitude.Should().NotBe(null);
            loc.Longitude.Should().NotBe(null);

            string serialized = Newtonsoft.Json.JsonConvert.SerializeObject(loc);

            serialized.Should().NotBeNullOrEmpty();

            var deserialized = JsonConvert.DeserializeObject<GeographicLocation>(serialized);

            deserialized.Should().NotBeNull();

            deserialized.ShouldBeEquivalentTo(loc);

            GeographicLocation loc2 = new GeographicLocation();

            const double expectLat = 33;
            const double expectLong = 22;

            loc2.Latitude = expectLat;
            loc2.Longitude = expectLong;

            serialized = Newtonsoft.Json.JsonConvert.SerializeObject(loc2);

            serialized.Should().NotBeNullOrEmpty();

            deserialized = JsonConvert.DeserializeObject<GeographicLocation>(serialized);

            deserialized.Should().NotBeNull();

            deserialized.ShouldBeEquivalentTo(loc2);
            deserialized.Latitude.Should().Be(expectLat);
            deserialized.Longitude.Should().Be(expectLong);
        }
Exemple #32
0
    static void Main()
    {
        // This static method provides the program entry point for a test
        // program that calculates the distance between a user-specified
        // GeographicLocation and a fixed GeographicLocation.

        // DO NOT MODIFY THIS STATIC METHOD.

        int latDegrees;
        uint latMinutes;
        uint latSeconds;
        int lonDegrees;
        uint lonMinutes;
        uint lonSeconds;

         GeographicLocation location0;
         GeographicLocation location1;

         Console.WriteLine( "\nGreat Circle Distance Estimator");

         Console.WriteLine( "\nThis program calculates the distance between a");
         Console.WriteLine( "location specified by the user and a location at");
         Console.WriteLine( "the University of Waterloo in the RCH Building.");

         Console.WriteLine( "\nLatitude Entry");

         Console.WriteLine( "\nEnter a latitude specified in DMS format.");
         Console.WriteLine( "    RCH Building is 43u00b028'13\"");
         Console.WriteLine( "    degrees = 43, minutes = 28, seconds = 13");

        latDegrees = getInteger( "degrees",  "latitude", -90, 90);

        if (latDegrees == -90 || latDegrees == 90)
        {
            latMinutes = 0;
            latSeconds = 0;
        }
        else
        {
            latMinutes = getUnsignedInteger( "minutes",  "latitude", 60u);
            latSeconds = getUnsignedInteger( "seconds",  "latitude", 60u);
        }

         Console.WriteLine( "\nLongitude Entry");

         Console.WriteLine( "\nEnter a longitude specified in DMS format.");
         Console.WriteLine( "    RCH Building is -80u00b032'27\"");
         Console.WriteLine( "    degrees = -80, minutes = 32, seconds = 27");

        lonDegrees = getInteger( "degrees",  "longitude", -180, 180);

        if (lonDegrees == -180 || lonDegrees == 180)
        {
            lonMinutes = 0;
            lonSeconds = 0;
        }
        else
        {
            lonMinutes = getUnsignedInteger( "minutes",  "longitude", 60);
            lonSeconds = getUnsignedInteger( "seconds",  "longitude", 60);
        }

        // The user-specified location is location 0
        location0 = new  GeographicLocation(
            latDegrees, latMinutes, latSeconds,
            lonDegrees, lonMinutes, lonSeconds);

        // The RCH building at UW is always location 1
        location1 = new  GeographicLocation(43, 28, 13, -80, 32, 27);

         Console.WriteLine( "\nSpecified Location = {0}", location0);
         Console.WriteLine( "RCH Building       = {0}", location1);

         Console.WriteLine(
             "\nThe distance from your location to RCH at UW is {0:F2} km.",
            location0.Distance(location1));
    }
Exemple #33
0
    public double Distance( GeographicLocation myLocation)
    {
        // This instance method calculates the distance from the current
        // instance location to another GeographicLocation specified by
        // a parameter that refers to the location.

        // DO NOT MODIFY THIS METHOD.

        double latitudeDD1 = myLocation.LatitudeRadians;
        double longitudeDD1 = myLocation.LongitudeRadians;
        double latitudeDD2 = LatitudeRadians;
        double longitudeDD2 = LongitudeRadians;

        double sinLambda =  Math.Sin(longitudeDD1 - longitudeDD2);
        double cosLambda =  Math.Cos(longitudeDD1 - longitudeDD2);

        double distance = NASA. Earth.EquatorialRadius *  Math.Atan2( Math.Sqrt(
             Math.Cos(latitudeDD1) * sinLambda *
             Math.Cos(latitudeDD1) * sinLambda +
            ( Math.Cos(latitudeDD2) *  Math.Sin(latitudeDD1) -
             Math.Sin(latitudeDD2) *  Math.Cos(latitudeDD1) *
            cosLambda) *
            ( Math.Cos(latitudeDD2) *  Math.Sin(latitudeDD1) -
             Math.Sin(latitudeDD2) *  Math.Cos(latitudeDD1) *
            cosLambda)),
            ( Math.Sin(latitudeDD2) *  Math.Sin(latitudeDD1) +
             Math.Cos(latitudeDD2) *  Math.Cos(latitudeDD1) *
            cosLambda));
        return (distance);
    }
Exemple #34
0
        public GeographicLocation[] getGeographicLocations(string zipcode)
        {
            if (String.IsNullOrEmpty(zipcode))
            {
                throw new ArgumentNullException("Must supply zipcode");
            }
            string statement = "SELECT * FROM ZIPCodes WHERE ZIPCode = @ZIPCODE;";
            SqlCommand command = new SqlCommand(statement);
            SqlParameter zipcodeParam = new SqlParameter("@ZIPCODE", SqlDbType.NVarChar, 5);
            zipcodeParam.Value = zipcode;
            command.Parameters.Add(zipcodeParam);

            DataTable results = query(command);
            if (results == null || results.Rows == null || results.Rows.Count == 0)
            {
                return null;
            }

            GeographicLocation[] locations = new GeographicLocation[results.Rows.Count];
            for (int i = 0; i < results.Rows.Count; i++)
            {
                GeographicLocation loc = new GeographicLocation();
                loc.Zipcode = zipcode;
                loc.ZipcodeType = results.Rows[i][1] as string;
                loc.CityName = results.Rows[i][2] as string;
                loc.CityType = results.Rows[i][3] as string;
                loc.CountyName = results.Rows[i][4] as string;
                loc.CountyFips = results.Rows[i][5] as string;
                loc.StateName = results.Rows[i][6] as string;
                loc.StateAbbreviation = results.Rows[i][7] as string;
                loc.StateFips = results.Rows[i][8] as string;
                loc.MsaCode = results.Rows[i][9] as string;
                loc.AreaCode = results.Rows[i][10] as string;
                loc.TimeZone = results.Rows[i][11] as string;
                loc.Utc = getInt(results.Rows[i][12]);
                loc.DaylightSavings = ((results.Rows[i][13] as string) == "Y");
                loc.Latitude = getDouble(results.Rows[i][14]);
                loc.Longitude = getDouble(results.Rows[i][15]);
                locations[i] = loc;
            }

            return locations;
        }
 public void GeographicLocation1()
 {
     IGeographicLocation g = new GeographicLocation(123.143, 52.1234);
     SerializeTest(g, "GeographicLocation1.xml");
 }