Пример #1
0
        public ActionResult GetSuggestedWeatherStationByGeocoordinates(double latitude, double longitude)
        {
            ActionResult         actionResult;
            DegreeDaysApi        degreeDaysApi       = new DegreeDaysApi(new AccountKey(this.apiKey_degreeDaysAccountKey), new SecurityKey(this.apiKey_degreeDaysSecurityKey));
            DatedDataSpec        datedDataSpec       = DataSpec.Dated(Calculation.HeatingDegreeDays(Temperature.Fahrenheit(65)), DatedBreakdown.Daily(Period.LatestValues(10)));
            LocationDataRequest  locationDataRequest = new LocationDataRequest(Location.LongLat(new LongLat(longitude, latitude)), new DataSpecs(new DataSpec[] { datedDataSpec }));
            LocationDataResponse locationData        = null;

            try
            {
                locationData = degreeDaysApi.DataApi.GetLocationData(locationDataRequest);
                if (locationData == null)
                {
                    return(base.Json(new MvcAjaxResponse(new ErrorInfo("We're sorry we could not find the suggested weather station for the coordinates provided."), false)));
                }
                if (locationData.StationId.ToString().Length > 0)
                {
                    return(base.Json(new MvcAjaxResponse(locationData.StationId.ToString())));
                }
                return(base.Json(new MvcAjaxResponse(new ErrorInfo("We're sorry we could not find the suggested weather station for the coordinates provided (response was blank)."), false)));
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                actionResult = base.Json(new MvcAjaxResponse(new ErrorInfo(exception.Message), false));
            }
            return(actionResult);
        }
Пример #2
0
        public ActionResult ValidateWeatherStationByStationId(string stationId)
        {
            ActionResult         actionResult;
            DegreeDaysApi        degreeDaysApi       = new DegreeDaysApi(new AccountKey(this.apiKey_degreeDaysAccountKey), new SecurityKey(this.apiKey_degreeDaysSecurityKey));
            DatedDataSpec        datedDataSpec       = DataSpec.Dated(Calculation.HeatingDegreeDays(Temperature.Fahrenheit(65)), DatedBreakdown.Daily(Period.LatestValues(10)));
            LocationDataRequest  locationDataRequest = new LocationDataRequest(Location.StationId(stationId), new DataSpecs(new DataSpec[] { datedDataSpec }));
            LocationDataResponse locationData        = null;

            try
            {
                locationData = degreeDaysApi.DataApi.GetLocationData(locationDataRequest);
                if (locationData == null)
                {
                    return(base.Json(new MvcAjaxResponse(new ErrorInfo(string.Concat("We're sorry we could not validate the weather station ", stationId, ".")), false)));
                }
                if (locationData.StationId.ToString().Length > 0)
                {
                    return(base.Json(new MvcAjaxResponse(locationData.StationId.ToString())));
                }
                return(base.Json(new MvcAjaxResponse(new ErrorInfo(string.Concat("We're sorry we could not validate the weather station ", stationId, " (response was blank).")), false)));
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                actionResult = base.Json(new MvcAjaxResponse(new ErrorInfo(exception.Message), false));
            }
            return(actionResult);
        }
Пример #3
0
        private async void SearchPaneSuggestionsRequested(
            SearchPane sender,
            SearchPaneSuggestionsRequestedEventArgs args)
        {
            SearchPaneSuggestionsRequestDeferral deferral = args.Request.GetDeferral();

            GeocodeRequestOptions requests = new GeocodeRequestOptions(args.QueryText);

            _searchManager  = MapView.SearchManager;
            _searchResponse = await _searchManager.GeocodeAsync(requests);

            foreach (GeocodeLocation locationData in _searchResponse.LocationData)
            {
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion(locationData.Address.FormattedAddress);
            }

            deferral.Complete();
        }
Пример #4
0
        /**
         * The Location Data Response
         *
         * @param status {@link byte} Status
         * @param locationType {@link byte} Location Type
         * @param coordinate1 {@link short} Coordinate 1
         * @param coordinate2 {@link short} Coordinate 2
         * @param coordinate3 {@link short} Coordinate 3
         * @param power {@link short} Power
         * @param pathLossExponent {@link ushort} Path Loss Exponent
         * @param locationMethod {@link byte} Location Method
         * @param qualityMeasure {@link byte} Quality Measure
         * @param locationAge {@link ushort} Location Age
         * @return the Task<CommandResult> command result Task
         */
        public Task <CommandResult> LocationDataResponse(byte status, byte locationType, short coordinate1, short coordinate2, short coordinate3, short power, ushort pathLossExponent, byte locationMethod, byte qualityMeasure, ushort locationAge)
        {
            LocationDataResponse command = new LocationDataResponse();

            // Set the fields
            command.Status           = status;
            command.LocationType     = locationType;
            command.Coordinate1      = coordinate1;
            command.Coordinate2      = coordinate2;
            command.Coordinate3      = coordinate3;
            command.Power            = power;
            command.PathLossExponent = pathLossExponent;
            command.LocationMethod   = locationMethod;
            command.QualityMeasure   = qualityMeasure;
            command.LocationAge      = locationAge;

            return(Send(command));
        }
Пример #5
0
        private async void SearchPaneSuggestionsRequested(
            SearchPane sender,
            SearchPaneSuggestionsRequestedEventArgs args)
        {
            SearchPaneSuggestionsRequestDeferral deferral = args.Request.GetDeferral();

            GeocodeRequestOptions requests = new GeocodeRequestOptions(args.QueryText);
            _searchManager = MapView.SearchManager;
            _searchResponse = await _searchManager.GeocodeAsync(requests);
            foreach (GeocodeLocation locationData in _searchResponse.LocationData)
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion(locationData.Address.FormattedAddress);

            deferral.Complete();
        }