예제 #1
0
        public JsonResponse <IEnumerable <PlaceMarker> > GetPlacemarker(string lat, string lon)
        {
            JsonResponse <IEnumerable <PlaceMarker> > res = new JsonResponse <IEnumerable <PlaceMarker> >();

            try
            {
                IList <GovHacDal.spGetPlaceMarker_Result> places = PlacemarkerRepository.GetPlaceMarker(lat, lon);
                List <PlaceMarker> convertedPlaces = new List <PlaceMarker>(places.Count());

                convertedPlaces.AddRange(places.Select(p => new PlaceMarker
                {
                    Description       = p.Description,
                    Name              = p.Name,
                    PlaceMarkerId     = p.ID,
                    PlaceMarkerTypeID = (p.PlacemarkerTypeID.HasValue) ? p.PlacemarkerTypeID.Value : 0,
                    Longitude         = p.Long,
                    Latitude          = p.Lat,
                    CategoryDesc      = p.CategoryDesc,
                    Distance          = p.Distance
                }));

                res.ResponseObject = convertedPlaces;
            }
            catch (Exception e)
            {
                res.Status  = ERROR_STATUS;
                res.Message = e.Message;
            }
            return(res);
        }
예제 #2
0
        public JsonResponse <IEnumerable <Image> > GetImages(string lat, string lon, int placeMarkerId)
        {
            JsonResponse <IEnumerable <Image> > res = new JsonResponse <IEnumerable <Image> >();

            try
            {
                IList <GovHacDal.spGetImages_Result> images = PlacemarkerRepository.GetImages(lat, lon, placeMarkerId);
                List <Image> convertedImages = new List <Image>(images.Count());


                convertedImages.AddRange(images.Select(im => new Image
                {
                    Description = im.Description,
                    Name        = im.Name,
                    ImageId     = im.ID,
                    ImageUrl    = im.ImageUrl,
                    Latitude    = im.Latitude,
                    Longitude   = im.Longitude,
                    ArceNumber  = im.AcreNumber
                }));

                if (placeMarkerId > 0)
                {
                    string name = PlacemarkerRepository.GetPlaceMarkerName(placeMarkerId, true);

                    name = "adelaide GPO sandbagging";
                    List <Image> troveImages = TroveApi.GetImages(name);

                    List <String> convertedImageUrls = convertedImages.Select(ci => ci.ImageUrl).ToList();
                    convertedImages.AddRange(troveImages.Where(im => convertedImageUrls.Contains(im.ImageUrl) == false));
                }
                res.ResponseObject = convertedImages;
            }
            catch (Exception e)
            {
                res.Status  = ERROR_STATUS;
                res.Message = e.Message;
            }
            return(res);
        }
예제 #3
0
        private void ProcessLastKnownLocations()
        {
            string lastKnownUrl = ConfigUtil.GetLastKnowLocationUrl();
            var    client       = new RestClient();
            var    request      = new RestRequest(lastKnownUrl, Method.GET);

            request.AddHeader("Content-Type", "application/json; charset=utf-8");
            //client.Execute<Person>(request)
            IRestResponse response = client.Execute(request);
            var           content  = response.Content;

            var jsonObj   = Newtonsoft.Json.Linq.JObject.Parse(response.Content);
            var jsonItems = jsonObj["items"];
            var lat       = jsonItems.First()["latitude"].ToString();
            var lon       = jsonItems.First()["longitude"].ToString();

            // get the place markers
            IList <spGetPlaceMarker_Result> markers = PlacemarkerRepository.GetPlaceMarker(lat, lon);

            StringBuilder sb = new StringBuilder();

            sb.Append("<h2>Places near you</h2>");
            sb.Append("<ul>");

            foreach (spGetPlaceMarker_Result res in markers)
            {
                sb.Append(string.Format("<li>{0}</li>", res.Name));
            }
            sb.Append("</ul>");

            string postUrl = ConfigUtil.GetPostToGlassUrl() + string.Format(PARAMETER, "Notification", sb.ToString(), lat, lon);

            request = new RestRequest(postUrl, Method.GET);
            // call the post to glass url
            response = client.Execute(request);
        }