Beispiel #1
0
        /// <summary>
        /// Returns specific details (neighborhood, local police district) using the specified longitude and latitude.
        /// It's used to determine where someone is in Philadelphia in relation to community resources and which
        /// neighborhood they're in.
        /// </summary>
        /// <param name="longitude">Longitude.</param>
        /// <param name="latitude">Latitude.</param>
        public async static Task <Area> Area(double longitude, double latitude)
        {
            JsonWebClient cli  = new JsonWebClient();
            var           resp = await cli.DoRequestJsonAsync <Area>(GetUri(PHILLY, $"/{longitude}/{latitude}/"));

            return(resp);
        }
Beispiel #2
0
        /// <summary>
        /// Returns the 10 day crime blotter.
        /// TODO: Rename this to 10 Day.
        /// </summary>
        /// <returns>The day crime data.</returns>
        /// <param name="span">A MapSpan object describing the viewport of the device the user can see.</param>
        /// <param name="currentFilter">The crime filter to use to limit what crime data is retured.</param>
        public async static Task <CrimeReport[]> Get30DayCrimeData(MapSpan span, Filter currentFilter)
        {
            // If the span is ridiculous we're not going to the server for data.
            if (span != null && span.LongitudeDegrees < 5)
            {
                JsonWebClient cli = new JsonWebClient();
                Debug.WriteLine("Span Center: {0},{1}   Longitude Degrees: {2}  Latitude Degrees: {3}",
                                span.Center.Longitude, span.Center.Latitude, span.LongitudeDegrees, span.LatitudeDegrees);

                string getUri = GetUri(GET_30DAY, string.Format("/{0}/{1}/{2}/{3}/{4}/",
                                                                span.Center.Longitude,
                                                                span.Center.Latitude,
                                                                span.LongitudeDegrees,
                                                                span.LatitudeDegrees,
                                                                Convert.ToInt32(currentFilter)));

                var resp = await cli.DoRequestJsonAsync <CrimeReport[]>(getUri);

                return(resp);
            }
            else
            {
                return(new CrimeReport[0]);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Returns the neighborhoods of Philly
        /// </summary>
        public async static Task <Neighborhood[]> Neighborhoods()
        {
            JsonWebClient cli  = new JsonWebClient();
            var           resp = await cli.DoRequestJsonAsync <Neighborhood[]>(GetUri(NEIGHBORHOOD, ""));

            return(resp);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the full crime report using the District Control Number identifier from police.
        /// </summary>
        /// <returns>The full crime report.</returns>
        /// <param name="DCN">Dcn.</param>
        public async static Task <FullCrimeReport> GetFullCrimeReport(string DCN)
        {
            JsonWebClient cli = new JsonWebClient();

            var resp = await cli.DoRequestJsonAsync <FullCrimeReport>(GetUri(FULLREPORT,
                                                                             $"/{DCN}/"));

            return(resp);
        }
Beispiel #5
0
        /// <summary>
        /// This pulls a hyper-local 10 day blotter based on a position and a radius distance.
        /// </summary>
        /// <returns>The local blotter.</returns>
        /// <param name="latitutde">Latitutde.</param>
        /// <param name="longitude">Longitude.</param>
        /// <param name="distance">Distance.</param>
        public async static Task <CrimeReport[]> GetLocalBlotter(double latitutde, double longitude, double distance)
        {
            JsonWebClient cli = new JsonWebClient();

            string getUri = GetUri(BLOTTER, string.Format($"/{latitutde}/{longitude}/{distance}/"));
            var    resp   = await cli.DoRequestJsonAsync <CrimeReport[]>(getUri);

            return(resp);
        }
Beispiel #6
0
        public async static Task <YTD[]> GetYTD(int neighborhood)
        {
            JsonWebClient cli = new JsonWebClient();

            Debug.WriteLine($"Requesting YTD crime totals for neighborhood ID: {neighborhood}");

            string getUri = GetUri(GETYTD, string.Format("/{0}/", neighborhood));
            var    resp   = await cli.DoRequestJsonAsync <YTD[]>(getUri);

            return(resp);
        }
Beispiel #7
0
        /// <summary>
        /// Gets the 10-day blotter given an array of neighborhood IDs. The Neighborhoods are found using the call to Neighborhoods().
        /// </summary>
        /// <returns>The blotter.</returns>
        /// <param name="neighborhoods">Neighborhoods.</param>
        public async static Task <CrimeReport[]> GetBlotter(int[] neighborhoods)
        {
            JsonWebClient cli = new JsonWebClient();

            string hoods = "";

            for (int i = 0; i < neighborhoods.Length; i++)
            {
                hoods += neighborhoods[i].ToString();
                if (i != neighborhoods.Length - 1)
                {
                    hoods += ",";
                }
            }

            string getUri = GetUri(BLOTTER, string.Format("/{0}/", hoods));

            var resp = await cli.DoRequestJsonAsync <CrimeReport[]>(getUri);

            return(resp);
        }