/// <summary> /// Gets sorted list of all Business Locations in the dataset by filter /// </summary> /// <param name="SearchQuery">Query to filter on</param> /// <param name="PageNumber">Current page number</param> /// <param name="PageSize">Number of items per page</param> /// <param name="OrderBy">Column name to sequence the list by</param> /// <param name="OrderByAscDesc">Sort direction</param> /// <returns>object PagedList</returns> public static PagedList<BusinessLocation> GetBusinessLocations(string SearchQuery, int PageNumber, int PageSize, string OrderBy, bool OrderByAscDesc) { //Create client to talk to OpenDat API Endpoint var client = new SodaClient(_APIEndPointHost, _AppToken); //get a reference to the resource itself the result (a Resouce object) is a generic type //the type parameter represents the underlying rows of the resource var dataset = client.GetResource <PagedList<BusinessLocation>>(_APIEndPoint4x4); //Build the select list of columns for the SoQL call string[] columns = new[] { "legal_name", "doing_business_as_name", "date_issued", "city", "state", "zip_code", "latitude", "longitude" }; //Column alias must not collide with input column name, i.e. don't alias 'city' as 'city' string[] aliases = new[] { "LegalName", "DBA", "IssuedOn" }; //using SoQL and a fluent query building syntax var soql = new SoqlQuery().Select(columns) .As(aliases) .Order((OrderByAscDesc) ? SoqlOrderDirection.ASC: SoqlOrderDirection.DESC, new[] { OrderBy }); if(!string.IsNullOrEmpty(SearchQuery)) { soql = new SoqlQuery().FullTextSearch(SearchQuery); } var results = dataset.Query<BusinessLocation>(soql); //page'em cause there might be quite a few PagedList<BusinessLocation> pagedResults = new PagedList<BusinessLocation>(results.ToList(), PageNumber, PageSize); return pagedResults; }
public void New_With_Username_Gets_Username() { string username = "******"; var client = new SodaClient(StringMocks.Host, StringMocks.NonEmptyInput, username, String.Empty); Assert.AreEqual(username, client.Username); }
public void New_With_Host_And_AppToken_Gets_Host_And_AppToken() { string host = "host"; string appToken = "appToken"; var client = new SodaClient(host, appToken); Assert.AreEqual(String.Format("https://{0}", host), client.Host); Assert.AreEqual(appToken, client.AppToken); }
/// <summary> /// Returns meta information about the dataset /// </summary> /// <returns></returns> public static string GetMeta() { //Create client to talk to OpenDat API Endpoint var client = new SodaClient(_APIEndPointHost, _AppToken); //read metadata of a dataset using the resource identifier (Socrata 4x4) var metadata = client.GetMetadata(_APIEndPoint4x4); return string.Format("{0} has {1} views. Last updated on {2:g}", metadata.Name, metadata.ViewsCount, metadata.RowsLastUpdated); }
private void readInfo(string repositoryUrl, string datasetId) { columnDeserialize = new Dictionary <string, string>(); url = repositoryUrl + "/resource/" + datasetId + ".json?"; var client = new SodaClient(repositoryUrl, "zzanGqreT6bAIRPuvhwn9yso3"); var dataset = client.GetResource <Object>(datasetId); foreach (var c in dataset.Columns) { columnDeserialize.Add(c.Name, c.SodaFieldName); } }
public static Dictionary <string, ParkingData> GetDataSet(string referenceName, string privateKey) { SodaClient client = new SodaClient("https://data.melbourne.vic.gov.au", privateKey); var dataset = client.GetResource <Dictionary <string, object> >(referenceName); IEnumerable <Dictionary <string, object> > rows = dataset.GetRows(5000); Console.WriteLine("Got {0} results. Dumping first results:", rows.Count()); _dataSet = ExtractData(rows); return(_dataSet); }
public void get(Location locate, int radius, int limit) { //initialize a new client //make sure you register for your own app token (http://dev.socrata.com/register) var client = new SodaClient("data.cityoftacoma.org", "faxxyxOUEBkwIxlgvMgFaEViQ"); //read metadata of a dataset using the resource identifier (Socrata 4x4) //var metadata = client.GetMetadata("iww5-t4fx"); //Console.WriteLine("{0} has {1} views.", metadata.Name, metadata.ViewsCount); //get a reference to the resource itself //the result (a Resouce object) is a generic type //the type parameter represents the underlying rows of the resource var dataset = client.GetResource <Dictionary <string, object> >("iww5-t4fx"); //collections of an arbitrary type can be returned //using SoQL and a fluent query building syntax string sql = "within_circle(location," + locate.latitude.ToString() + "," + locate.longitude.ToString() + "," + radius.ToString() + ")"; var soql = new SoqlQuery().Where(sql).Limit(limit); var results = dataset.Query(soql); foreach (var row in results) { var tmp = new Fire(); if (0 != row.Count) { //foreach (var vv in row) //Console.WriteLine(vv); try { tmp.intersection_address = row["location_address"].ToString(); tmp.fire_generalcause = row["fire_generalcause"].ToString(); tmp.firetype = row["firetype"].ToString(); tmp.time1 = row["firstunitturnout"].ToString(); tmp.time2 = row["incidentclosed"].ToString(); tmp.date = row["incidentdate"].ToString().Substring(0, 10); tmp.estimatedtotalfireloss = row["estimatedtotalfireloss"].ToString(); tmp.loc.city = row["city"].ToString(); tmp.loc.state = row["state"].ToString(); tmp.loc.zipcode = row["zipcode"].ToString(); tmp.loc.latitude = float.Parse(row["latitude"].ToString()); tmp.loc.longitude = float.Parse(row["longitude"].ToString()); }catch (Exception e) { Console.WriteLine("Error occurred in FireIncident entrance"); } } list.Add(tmp); } }
public void get(Location locate, int radius, int limit) { //https://data.cityoftacoma.org/resource/kjk6-j7c9.json var client = new SodaClient("data.cityoftacoma.org", "faxxyxOUEBkwIxlgvMgFaEViQ"); var dataset = client.GetResource <Dictionary <string, object> >("kjk6-j7c9"); string sql = "within_circle(collision_location," + locate.latitude.ToString() + "," + locate.longitude.ToString() + "," + radius.ToString() + ")"; var soql = new SoqlQuery().Where(sql).Limit(limit); var results = dataset.Query(soql); foreach (var row in results) { if (0 != row.Count) { try { Collision collision = new Collision { }; try { collision.most_severe_injury_type = row["most_severe_injury_type"].ToString(); } catch (Exception e) { } try { collision.lighting_conditions = row["lighting_conditions"].ToString(); } catch (Exception e) { } try { collision.jurisdiction = row["jurisdiction"].ToString(); } catch (Exception e) { } try { collision.weather = row["weather"].ToString(); } catch (Exception e) { } try { collision.date = row["date"].ToString(); }catch (Exception e) {} string collision_location = row["collision_location"].ToString(); string coordinates = collision_location.Substring(collision_location.IndexOf("coordinates") + 13).Trim('[', ']', '}', '{', '\n', '\r', ' ', '\t'); //Console.WriteLine(float.Parse(coordinates.Split(',')[0])); collision.coordinate.latitude = float.Parse(coordinates.Split(',')[1]); collision.coordinate.longitude = float.Parse(coordinates.Split(',')[0]); collision.place = collision.coordinate.reverseGeocoding(); list.Add(collision); } catch (Exception e) { //Console.WriteLine("Error traffic data entrance"); //https://data.cityofchicago.org/resource/6zsd-86xi.json? //$where=date between '2018-02-27T12:00:00' and '2018-03-04T14:00:00' } } } }
public DataTable ShowTableDeptoFilter(string depto) { var client = new SodaClient("https://www.datos.gov.co", "4VQQ9iZluaLN4aeY2wbOFlhF9"); var dataset = client.GetResource <Object>("ysq6-ri4e"); var rows = dataset.GetRows(); var table = new DataTable(); var js = JsonConvert.SerializeObject(rows); List <Record> RecordList = JsonConvert.DeserializeObject <List <Record> >(js); table = ToDataTableDeptoFilter(RecordList, depto); return(table); }
/// <summary> /// Assisted by code from https://dev.socrata.com/foundry/data.cityofnewyork.us/fhrw-4uyv /// queried DB - https://data.cityofnewyork.us /// API KEY - PVGjhHLj8Svy7Ryz0uJgW9IBh /// loadDB connects to the database, sends the query and then returns the data /// </summary> /// <returns>Returns the dataset of the query to main</returns> public IEnumerable <Dictionary <string, object> > LoadDB(DateTime date) { SODA.SodaClient client = new SodaClient("https://data.cityofnewyork.us", "PVGjhHLj8Svy7Ryz0uJgW9IBh"); /// <remarks> /// The documentation on the web is outdated. /// The .NET library has been updated to no longer allow generic typing. /// You must use either Dictionary(String,Object) - use <> but not allowed in XML comments /// OR a user-defined json serializable class - their documentation does not explain how to do this /// well enough, however so we are sticking with the Generic Collection specified /// </remarks>> SODA.Resource <Dictionary <string, object> > dataset = client.GetResource <Dictionary <string, object> >("fhrw-4uyv"); SoqlQuery soql = this.GetQueryDate(date); IEnumerable <Dictionary <string, object> > results = dataset.Query <Dictionary <string, object> >(soql); return(results); }
public DataTable ShowPage(int nPage) { var rowsPerPage = 20; var x = (nPage - 1) * rowsPerPage; var client = new SodaClient("https://www.datos.gov.co", "4VQQ9iZluaLN4aeY2wbOFlhF9"); var dataset = client.GetResource <Object>("ysq6-ri4e"); var rows = dataset.GetRows(limit: rowsPerPage, offset: x); var table = new DataTable(); var js = JsonConvert.SerializeObject(rows); List <Record> RecordList = JsonConvert.DeserializeObject <List <Record> >(js); table = ToDataTable(RecordList); return(table); }
static void Main(string[] args) { // Get set up data and get data. var client = new SodaClient("https://data.sfgov.org", "tOvbugsbjxkiUpNOfwfNmz4Sk"); string[] columns = { "dayoftheweekstr", "starttime", "endtime", "location", "locationdesc", "applicant", "longitude", "latitude" }; var soql = new SoqlQuery().Select(columns); var dataset = client.GetResource <FoodTruck>("jjew-r69b"); var results = dataset.GetRows(limit: 5000); List <FoodTruck> openTrucks = (from FoodTruck item in results where item.IsOpen(DateTime.Now) select item).ToList(); openTrucks.Sort(); // Queue is for paging results. Queue <FoodTruck> queueTrucks = new Queue <FoodTruck>(openTrucks); Console.WriteLine(openTrucks.Count + " trucks open at " + DateTime.Now.ToString()); Console.WriteLine("NAME - LOCATION"); while (queueTrucks.Count > 0) { for (int i = 0; i < 10; i++) { if (queueTrucks.Count == 0) { break; } queueTrucks.Dequeue().Display(); } Console.ReadKey(); } Console.WriteLine("End of list."); Console.ReadKey(); }
public OutageBase() { var domain = System.Web.Configuration.WebConfigurationManager.AppSettings["DataDomain"]; var datasetId = System.Web.Configuration.WebConfigurationManager.AppSettings["DataSetId"]; var appId = System.Web.Configuration.WebConfigurationManager.AppSettings["ApplicationId"]; //initialize a new client //make sure you register for your own app token (http://dev.socrata.com/register) var client = new SodaClient(domain, appId); dataset = client.GetResource<Dictionary<string, object>>(datasetId); allRows = dataset.GetRows(); var causes = allRows .GroupBy(r => r["cause"]) .Select(g => new { Cause = g.Key, Count = g.Count() }); Timer = new Lazy<Timer>(() => new Timer(SendMessage, null, TimeSpan.Zero, TimeSpan.FromSeconds(intervalSeconds))); }
public void get(Location locate, int radius, int limit) { var client = new SodaClient("data.cityoftacoma.org", "faxxyxOUEBkwIxlgvMgFaEViQ"); var dataset = client.GetResource <Dictionary <string, object> >("vzsr-722t"); string sql = "within_circle(intersection," + locate.latitude.ToString() + "," + locate.longitude.ToString() + "," + radius.ToString() + ")"; var soql = new SoqlQuery().Where(sql).Limit(limit); var results = dataset.Query(soql); foreach (var row in results) { var tmp = new Crime(); if (0 != row.Count) { //foreach (var vv in row) //Console.WriteLine(vv); try { tmp.intersection_address = row["intersection_address"].ToString(); tmp.date = row["occurred_on"].ToString().Substring(0, 10); tmp.time = row["approximate_time"].ToString(); tmp.crime = row["crime"].ToString(); tmp.loc.city = row["intersection_city"].ToString(); tmp.loc.state = row["intersection_state"].ToString(); tmp.loc.zipcode = locate.zipcode; //longthy string intersection = row["intersection"].ToString(); String coordinates = intersection.Substring(intersection.IndexOf("coordinates") + 13).Trim('[', ']', '}', '{', '\n', '\r', ' ', '\t'); //Console.WriteLine(coordinates.Split(',')[1]); tmp.loc.latitude = float.Parse(coordinates.Split(',')[1]); tmp.loc.longitude = float.Parse(coordinates.Split(',')[0]); }catch (Exception e) { Console.WriteLine("Error occurred in Crime entrance"); } } list.Add(tmp); } }
public void readInfo() { mapa = new Dictionary <string, string>(); dataGridView1.Columns.Clear(); checkedListBox1.Items.Clear(); string repository = repositoryUrl.Text; string id = datasetId.Text; url = repository + "/resource/" + id + ".json?"; var client = new SodaClient(repository, "zzanGqreT6bAIRPuvhwn9yso3"); var dataset = client.GetResource <Object>(id); foreach (var c in dataset.Columns) { checkedListBox1.Items.Add(c.Name, false); mapa.Add(c.Name, c.SodaFieldName); dataGridView1.Columns.Add(c.SodaFieldName, c.Name); } }
/// <summary> /// Assisted by code from https://dev.socrata.com/foundry/data.cityofnewyork.us/fhrw-4uyv /// queried DB - https://data.cityofnewyork.us /// API KEY - PVGjhHLj8Svy7Ryz0uJgW9IBh /// loadDB connects to the database, sends the query and then returns the data /// </summary> /// <returns>Returns the da taset of the query to main</returns> public IEnumerable <Dictionary <string, object> > LoadDB() { /// <remarks> /// This requires the SODA library /// It can be installed from NuGet in Visual studio using /// Install-Package CSM.SodaDotNet /// </remarks>> SODA.SodaClient client = new SodaClient("https://data.cityofnewyork.us", "PVGjhHLj8Svy7Ryz0uJgW9IBh"); /// <remarks> /// The documentation on the web is outdated. /// The .NET library has been updated to no longer allow generic typing. /// You must use either Dictionary(String,Object) - use <> but not allowed in XML comments /// OR a user-defined json serializable class - their documentation does not explain how to do this /// well enough, however so we are sticking with the Generic Collection specified /// </remarks>> SODA.Resource <Dictionary <string, object> > dataset = client.GetResource <Dictionary <string, object> >("fhrw-4uyv"); /// <summary> /// instantiate our object and get our query from GetQueryDate() /// </summary> ManageDB test = new ManageDB(); SODA.SoqlQuery soql = test.GetQueryDate(); /// <summary> /// Query sends our query to our pre-defined location and returns an IEnumerable which we assign to results /// results now contains the results of our query /// </summary> IEnumerable <Dictionary <string, object> > results = dataset.Query <Dictionary <string, object> >(soql); /// <summary> /// Testing to make sure that our query returned results /// Will be changed to throw an error instead of printing a value /// </summary> int SizeOfList; test.TestIEnum(ref results, out SizeOfList); Console.WriteLine(SizeOfList); return(results); }
public static PagedList <BusinessLocation> GetBusinessLocations(string SearchQuery, int PageNumber, int PageSize, string OrderBy, bool OrderByAscDesc) { var client = new SodaClient(_APIEndPointHost, _AppToken); var dataset = client.GetResource <PagedList <BusinessLocation> >(_APIEndPoint4x4); var columns = new[] { "company_name", "sub_subindustry", "phone", " location_1" }; var aliases = new[] { "CompanyName", "SubIndustry", "fone", "Location" }; var soql = new SoqlQuery().Select(columns) .As(aliases) .Order((OrderByAscDesc) ? SoqlOrderDirection.ASC : SoqlOrderDirection.DESC, new[] { OrderBy }); if (!string.IsNullOrWhiteSpace(SearchQuery)) { soql = new SoqlQuery().FullTextSearch(SearchQuery); } var results = dataset.Query <BusinessLocation>(soql); PagedList <BusinessLocation> pagedResults = new PagedList <BusinessLocation>(results.ToList(), PageNumber, PageSize); return(pagedResults); }
static void Main(string[] args) { var targetStoresInUSA = new List<Store>(); StateURLCollection.URLs.ForEach(stateURL => { var stateStoresDOM = CQ.CreateFromUrl(stateURL); var storeJSON = stateStoresDOM["#primaryJsonResponse"].Text(); var state = JsonConvert.DeserializeObject<State>(storeJSON); targetStoresInUSA = targetStoresInUSA.Concat(state.Stores).ToList(); Console.WriteLine("Processed: {0}", state.StateName); }); var sodaClient = new SodaClient("opendata.socrata.com", ConfigurationManager.AppSettings["socrataAPIKey"], ConfigurationManager.AppSettings["socrataUsername"], ConfigurationManager.AppSettings["socrataPassword"]); var targetStoresInUSAJSON = JsonConvert.SerializeObject(targetStoresInUSA); Console.WriteLine("Upserting to Socrata"); sodaClient.Upsert(targetStoresInUSAJSON, SodaDataFormat.JSON, ConfigurationManager.AppSettings["socrataResourceId"]); }
protected void Page_Load(object sender, EventArgs e) { lbldatetime.Text = DateTime.Now.ToString(); var client = new SodaClient("https://health.data.ny.gov", "qT8KiMVFytMqdoi6OmsjOgKTN"); //var dataset = client.GetResource<Dictionary<string, object>>("7xgt-tyms"); var dataset = client.GetResource <ExtFac>("7xgt-tyms"); var soql = new SoqlQuery().Select("facility_name", "main_site_name", "cooperator_name", "address1", "address2", "city", "state", "fac_zip", "fac_phone", "cnty_cd", "latitude", "longitude", "fac_desc_short") .Where("(fac_desc_short='HOSP-EC' OR fac_desc_short='DTC-EC') AND ((main_site_name LIKE '%Westchester Medical Center%') OR (main_site_name like '%Langone%') OR (cooperator_name LIKE '%Northwell%') OR (main_site_name like '%Presby%' AND operator_city = 'New York')) "); //var results = dataset.Query<Dictionary<string, object>>(soql); var results = dataset.Query <ExtFac>(soql); //lblcount.Text = " Total record count: " + results.Count().ToString(); //var myObjectDT = JsonConvert.DeserializeObject<DataTable>(results.ToString()); //var myObject = JsonConvert.DeserializeObject(results.ToString()); grid1.DataSource = results; grid1.DataBind(); }
public void TestSetup() { mockClient = new SodaClient(StringMocks.Host, StringMocks.NonEmptyInput); mockMetadata = new ResourceMetadata(mockClient); }
public MasterListService(SodaClient sodaClient, SoqlQuery soqlQuery) { this.sodaClient = sodaClient; this.soqlQuery = soqlQuery; }
public void TestSetup() { mockClient = new SodaClient(StringMocks.Host, StringMocks.NonEmptyInput); }
public void TestSetup() { exampleUrl = "http://www.example.com"; exampleUri = new Uri(exampleUrl); mockClient = new SodaClient(StringMocks.Host, StringMocks.NonEmptyInput); }
public IActionResult MegaMillions() { // get drawing records var sodaHost = _appSettings.MegaMillions.HostUrl; var soda4x4 = _appSettings.MegaMillions.TableId; var sodaAppToken = _appSettings.SODA.AppToken; var client = new SodaClient(sodaHost, sodaAppToken); // go max one year back to look at data var soql = new SoqlQuery().Select("draw_date", "winning_numbers", "mega_ball", "multiplier") .Where($"draw_date > '{DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd")}'").Order(SoqlOrderDirection.DESC, "draw_date"); var dataset = client.GetResource <MegaMillionsResults>(soda4x4); var results = dataset.Query(soql); // create drawing collection var drawings = new List <Drawing>(); // var ballStatList = new List<BallsStats>(); // set drawing limits var maxBallValue = _appSettings.MegaMillions.MaxBallValue; var maxMegaBallValue = _appSettings.MegaMillions.MaxMegaBallValue; var ballCount = _appSettings.MegaMillions.BallCount; // calculate next drawing date var nextDrawDate = CalculateNextDrawDate(new List <DayOfWeek> { DayOfWeek.Tuesday, DayOfWeek.Thursday }); // build base drawing collection foreach (var draw in results) { var winningNumbers = draw.winning_numbers.Split(' '); var drawing = new Drawing { DrawDate = DateTime.Parse(draw.draw_date) }; foreach (var nbr in winningNumbers) { var idx = Array.IndexOf(winningNumbers, nbr) + 1; var ball = new DrawnBall { Id = Convert.ToInt32(nbr), Seq = idx }; drawing.Balls.Add(ball); } var megaBall = new DrawnBall { Id = Convert.ToInt32(draw.mega_ball), Seq = 6 }; drawing.Balls.Add(megaBall); drawings.Add(drawing); } var ballStatsList = BuildStats(maxBallValue, ballCount, drawings, nextDrawDate, maxMegaBallValue); var autoPcikList = GetAutoPicks(nextDrawDate, ballStatsList, maxBallValue, true); var model = BuildViewModel(nextDrawDate, autoPcikList, ballStatsList); return(View(model)); }
public SodaService(IAppSettingsManager appSettingsManager, IEnumerable <IQueryBuilder> queryBuilders, SodaClient sodaClient, SoqlQuery soqlQuery) { _appSettingsManager = appSettingsManager; _queryBuilders = queryBuilders; _sodaClient = sodaClient; _soqlQuery = soqlQuery; }
public static List <Place> getPlaces() { // RetrievAffordability(); var client = new SodaClient("data.seattle.gov", "eDhP3BH0cLYPgbEC56eNWnraC"); var dataset = client.GetResource <Dictionary <string, object> >("82su-5fxf"); var theseRows = dataset.GetRows(2500); // var placelistall = new List<Place>(); var placelist = new List <Place>(); Dictionary <string, Neighborhood> neighCentroids = new Dictionary <string, Neighborhood>(); string id = ""; int idint = 3; /* * Place testplace = new Place(); * testplace.ID = "1"; * testplace.LatitudeStr = "127.23432"; * testplace.LongitudeStr = "-199.232343"; * testplace.Latitude = (47.62011337); * testplace.Longitude = (-122.316169); * * Place testplace2 = new Place(); * testplace2.ID = "2"; * testplace2.LatitudeStr = "127.23432"; * testplace2.LongitudeStr = "-199.232343"; * testplace2.Latitude = (47.62011337); * testplace2.Longitude = (-122.316169); * * placelist.Add(testplace); * placelist.Add(testplace2); */ foreach (var item in theseRows) { Place thisPlace = new Place(); thisPlace.distnorm = 1; thisPlace.ID = idint.ToString(); bool skip1 = false; thisPlace.Type = "regular"; if (item.ContainsKey("city_feature")) { thisPlace.Type = (string)item["city_feature"]; } if (thisPlace.Type == "Boat Launches" || thisPlace.Type == "Cemeteries" || thisPlace.Type == "Drivers Licenses" || thisPlace.Type == "Emission Inspections" || thisPlace.Type == "Fire Stations" || thisPlace.Type == "Fishing" || thisPlace.Type == "Hospitals" || thisPlace.Type == "Light Rail" || thisPlace.Type == "Monorail" || thisPlace.Type == "ParkNRide" || thisPlace.Type == "Pet License Sales" || thisPlace.Type == "Police Precincts" || thisPlace.Type == "South Lake Union Trolley" || thisPlace.Type == "Traffic Cameras" || thisPlace.Type == "Transfer Stations") { skip1 = true; } if (skip1 == false) { thisPlace.DisplayName = "none"; if (item.ContainsKey("common_name")) { thisPlace.DisplayName = (string)item["common_name"]; } /* * * if (item.ContainsKey("address")) * { * thisPlace.Address = (string)item["address"]; * } * if (item.ContainsKey("website")) * { * //thisPlace.Website = (string)item["website"]; * * } */ thisPlace.LongitudeStr = (string)item["longitude"]; thisPlace.LatitudeStr = (string)item["latitude"]; thisPlace.Longitude = Convert.ToDouble(thisPlace.LongitudeStr); thisPlace.Latitude = Convert.ToDouble(thisPlace.LatitudeStr); // thisPlace.Neighborhood = (string)item["common_name"]; bool skip = false; if (idint > 2000) { skip = true; } ; if (String.IsNullOrEmpty(thisPlace.LatitudeStr) || (String.IsNullOrEmpty(thisPlace.LongitudeStr)) || (thisPlace.Longitude == 0) || (thisPlace.Latitude == 0)) { skip = true; } if (skip == false) { Console.WriteLine(thisPlace.Longitude + " " + thisPlace.Latitude); RetrieveFormatedAddress(thisPlace.LatitudeStr, thisPlace.LongitudeStr, thisPlace); placelist.Add(thisPlace); } idint = idint + 1; } //end skip } //end for each row hear foreach (Place currentPlace in placelist) { string thishood = ""; if (currentPlace.NestedNeighborhood != "") { thishood = currentPlace.NestedNeighborhood; if (thishood == "" && currentPlace.Neighborhood != "") { thishood = currentPlace.Neighborhood; if (thishood == "" && currentPlace.City != "") { thishood = currentPlace.City; } } } if (thishood != "" && thishood != null) { if (!neighCentroids.Keys.Contains(thishood)) { Neighborhood thisNeighborhood = new Neighborhood(); thisNeighborhood.Name = thishood; thisNeighborhood.LatitudeSum = currentPlace.Latitude; thisNeighborhood.LongitudeSum = currentPlace.Longitude; thisNeighborhood.LatitudeN = 1; thisNeighborhood.LongitudeN = 1; thisNeighborhood.City = currentPlace.City; currentPlace.hood = thishood; neighCentroids.Add(thishood, thisNeighborhood); } else { neighCentroids[thishood].LatitudeSum = neighCentroids[thishood].LatitudeSum + currentPlace.Latitude; neighCentroids[thishood].LongitudeSum = neighCentroids[thishood].LongitudeSum + currentPlace.Longitude; neighCentroids[thishood].LatitudeN = neighCentroids[thishood].LatitudeN + 1; neighCentroids[thishood].LongitudeN = neighCentroids[thishood].LongitudeN + 1; } } } // List<Place> nPlaces = new List<Place>(); double maxdist = 0; foreach (Neighborhood thisNeigh in neighCentroids.Values) { thisNeigh.LatitudeCentroid = thisNeigh.LatitudeSum / thisNeigh.LatitudeN; thisNeigh.LongitudeCentroid = thisNeigh.LongitudeSum / thisNeigh.LongitudeN; Place nPlace = new Place(); nPlace.distnorm = 1; nPlace.Latitude = thisNeigh.LatitudeCentroid; nPlace.Longitude = thisNeigh.LongitudeCentroid; nPlace.LatitudeStr = thisNeigh.LatitudeCentroid.ToString(); nPlace.LongitudeStr = thisNeigh.LongitudeCentroid.ToString(); nPlace.Type = "centroid"; nPlace.DisplayName = thisNeigh.Name; Debug.WriteLine("adding neighborhood: " + thisNeigh.Name); thisNeigh.DistanceSum = 0; double count = 0; //getting hubbiness measure here foreach (Place yPlace in placelist) { if (thisNeigh.Name == yPlace.hood) { // c2 = a2 + b2 double distance = Math.Sqrt(Math.Pow((thisNeigh.LatitudeCentroid - yPlace.Latitude), 2) + (Math.Pow((thisNeigh.LongitudeCentroid - yPlace.Longitude), 2))); thisNeigh.DistanceSum = thisNeigh.DistanceSum + distance; count = count + 1; } } if (count > 0) { thisNeigh.DistanceAve = thisNeigh.DistanceSum / count; if (thisNeigh.DistanceAve > maxdist) { maxdist = thisNeigh.DistanceAve; } } //inverted to the higher the number, them more dense the hub; nPlace.distnorm = 1 - (thisNeigh.DistanceAve / maxdist); /*meant was div by 0; */ if (nPlace.distnorm == null) { nPlace.distnorm = 1; } placelist.Add(nPlace); } // foreach (Place item in Places.Values) // { // placelist.Add(item); //} // string myJsonString = JsonConvert.SerializeObject(placelist); // object thisobject = "{id: happy, lat: 30}"; // return thisobject; return(placelist); }
public void New_With_Http_Host_Enforces_Https_Host(string input) { var client = new SodaClient(input, "appToken"); StringAssert.StartsWith("https", client.Host); }
public sodaproxi() { client = new SodaClient(URL_PORTAL, APP_TOKEN, USUARIO, CLAVE); }
/// <summary> /// Initialize a new ResourceMetadata object with the specified <see cref="SodaClient"/>. /// </summary> /// <param name="client">A <see cref="SodaClient"/> used to access this ResourceMetadata on a Socrata Host.</param> /// <remarks> /// The constructor is internal because ResourceMetadata should be obtained through a SodaClient or Resource object. /// </remarks> internal ResourceMetadata(SodaClient client) { if (client == null) throw new ArgumentNullException("client", "Cannot initialize a ResourceMetadata with null SodaClient"); Client = client; }
public Connection() { client = new SodaClient("https://www.datos.gov.co", "0ZxbhxPYsq48evOeRDVFeHuCA"); dataset = client.GetResource <Dictionary <String, String> >("ysq6-ri4e"); }