Esempio n. 1
0
        // GET api/<controller>
        public IGeoCodeResult Query(GeoQuery q)
        {
            string key = string.Empty;
            string query = string.Empty;
            string provider = "Google";
            IGeoProviderConfig config;
            IGeoProvider GeoProvider = null;

            IGeoCodeResult result = new GeoCodeResult();

            if (!String.IsNullOrEmpty(q.Query) && !String.IsNullOrEmpty(q.Providers))
            {
                query = q.Query;
                // we have a search
                provider = q.Providers.Replace("KEY", "");
                if (q.Providers.Contains("KEY"))
                {
                    key = q.Key;
                }

                switch (provider)
                {
                    case "Google":
                        config = new GoogleGmapConfig();
                        GeoProvider = new GoogleGmap(config);
                        break;
                    case "Bing":
                        config = new BingMapConfig().SetKey(key);
                        GeoProvider = new BingMap(config);
                        break;
                    case "MapQuest":
                        config = new MapQuestConfig().SetKey(key);
                        GeoProvider = new MapQuestMap(config);
                        break;
                    case "Open Streets":
                        config = new OpenStreetMapConfig().SetUserAgent("your email here yo");
                        GeoProvider = new OpenStreetMap(config);
                        break;
                    case "YahooPlaces":
                        config = new YahooPlaceFinderConfig().SetKey(key);
                        GeoProvider = new YahooPlaceFinder(config);
                        break;
                    case "CloudMade":
                        config = new CloudMadeConfig().SetKey(key);
                        GeoProvider = new CloudMade(config);
                        break;

                }

                GeoProvider = GeoProvider != null ? GeoProvider : new GoogleGmap();

                GeoCoder gc = new GeoCoder(GeoProvider);

                result = gc.GetCoordinates(query);

            }
            return result;
        }
Esempio n. 2
0
        public void GeoCoderYahooPlaceFinder()
        {
            YahooPlaceFinderConfig yph = new YahooPlaceFinderConfig().SetKey(YahooAppId);
            YahooPlaceFinder       ypf = new Lucuma.Libs.YahooPlaceFinder(yph);

            GeoCoder g = new GeoCoder(ypf);

            var Expected = new {
                Latitude  = 30.267605,
                Longitude = -97.742984
            };

            IGeoCodeResult Target = new GeoCodeResult();

            Target = g.GetCoordinates("Austin, TX");
            Assert.AreEqual(Expected.Latitude, Target.Latitude);
            Assert.AreEqual(Expected.Longitude, Target.Longitude);
        }
Esempio n. 3
0
        public void YahooPlaceFinder()
        {
            YahooPlaceFinder g = new YahooPlaceFinder();

            var Expected = new { Latitude = 30.267605, Longitude =  -97.742984 };

            IGeoCodeResult Target = new GeoCodeResult();

            Target = g.GetCoordinates("Austin, TX");
            Assert.AreEqual(Expected.Latitude, Target.Latitude);
            Assert.AreEqual(Expected.Longitude, Target.Longitude);
        }
Esempio n. 4
0
        public void GeoCoderYahooPlaceFinder()
        {
            YahooPlaceFinderConfig yph = new YahooPlaceFinderConfig().SetKey(YahooAppId);
            YahooPlaceFinder ypf = new Lucuma.Libs.YahooPlaceFinder(yph);

            GeoCoder g = new GeoCoder(ypf);

               var Expected = new {
               Latitude = 30.267605,
               Longitude = -97.742984
               };

            IGeoCodeResult Target = new GeoCodeResult();

            Target = g.GetCoordinates("Austin, TX");
            Assert.AreEqual(Expected.Latitude, Target.Latitude);
            Assert.AreEqual(Expected.Longitude, Target.Longitude);
        }