Bridges-C++  3.2.0
Bridges(C++API)
Public Member Functions | List of all members
bridges::DataSource Class Reference

#include <DataSource.h>

Detailed Description

This class provides an API to various data sources used in BRIDGES.

BRIDGES currently supports a few external datasets for use with BRIDGES assignments: USGIS Earthquake Tweeet streaming data feed, IMDB (file), Book metadata collection, IGN Game Data, Shakespear book/poem meta data, etc.

Functions are provided that access a user specified number of data records; objects of the appropriate type are returned as a list.

Public Member Functions

 DataSource (bridges::Bridges *br=nullptr)
 
 DataSource (bridges::Bridges &br)
 
vector< GamegetGameData ()
 Get meta data of the IGN games collection. More...
 
vector< ActorMovieIMDBgetActorMovieIMDBData (int number=0)
 Get ActorMovie IMDB Data Data is retrieved, formatted into a list of ActorMovieIMDB objects. More...
 
vector< ActorMovieIMDBgetActorMovieIMDBData2 ()
 Get ActorMovie IMDB Data Data is retrieved, formatted into a list of ActorMovieIMDB objects. More...
 
vector< EarthquakeUSGSgetEarthquakeUSGSData (int number=0)
 Get USGS earthquake data USGS Tweet data (https://earthquake.usgs.gov/earthquakes/map/) retrieved, formatted into a list of EarthquakeUSGS objects. More...
 
vector< ShakespearegetShakespeareData (string type="", bool textonly=false)
 Get data of Shakespeare works (plays, poems) More...
 
Song getSong (string songTitle, string artistName)
 Get data of a particular songs (including lyrics) using the Genius API (https://docs.genius.com/), given the song title and artist name. Valid endpoints: http://bridgesdata.herokuapp.com/api/songs/find/ Valid queryParams: song title, artist name. More...
 
vector< SonggetSongData ()
 Get data of the songs (including lyrics) using the Genius API https://docs.genius.com/ Valid endpoints: https://bridgesdata.herokuapp.com/api/songs/. More...
 
vector< GutenbergBookgetGutenbergBookData (int num=0)
 Get meta data of the Gutenberg book collection. This function retrieves, and formats the data into a list of GutenbergBook objects. More...
 
vector< CancerIncidencegetCancerIncidenceData (int num=0)
 Retrieves the CDC dataset of Cancer Incidence. Data is retrieved into a vector of records See CancerIncidence class for more information. More...
 
OSMData getOSMDataFromJSON (const string &osm_json)
 Retrieves the Open Street Map data from a prebuilt JSON of OSM dataset. More...
 
OSMData getOSMData (double lat_min, double long_min, double lat_max, double long_max, string level="default")
 Get OpenStreetMap data given a bounding rectangle of lat/long values. More...
 
void getAmenityData (double minLat, double minLon, double maxLat, double maxLon, std::string amenity)
 
void getAmenityData (const std::string &location, const std::string &amenity)
 
OSMData getOSMData (string location, string level="default")
 
bridges::GraphAdjList< int, std::string > getGraphFromAssignment (const std::string &user, int assignment, int subassignment=0)
 old interface for the OSM data set. More...
 
bridges::ColorGrid getColorGridFromAssignment (const std::string &user, int assignment, int subassignment=0)
 
std::vector< MovieActorWikidatagetWikidataActorMovie (int yearbegin, int yearend)
 This function returns the Movie and Actors playing in them between two years. More...
 
ElevationData getElevationData (double latitMin, double longitMin, double latitMax, double longitMax, double res=0.0166)
 
ElevationData getElevationDataFromJSON (string elev_json)
 

Constructor & Destructor Documentation

◆ DataSource() [1/2]

bridges::DataSource::DataSource ( bridges::Bridges br = nullptr)
inline

◆ DataSource() [2/2]

bridges::DataSource::DataSource ( bridges::Bridges br)
inline

Member Function Documentation

◆ getActorMovieIMDBData()

vector<ActorMovieIMDB> bridges::DataSource::getActorMovieIMDBData ( int  number = 0)
inline

Get ActorMovie IMDB Data Data is retrieved, formatted into a list of ActorMovieIMDB objects.

Parameters
numberthe number of actor/movie pairs, but currently unused, returns all records.
Exceptions
Exceptionif the request fails
Returns
a list of ActorMovieIMDB objects, but only actor and movie fields in this version

◆ getActorMovieIMDBData2()

vector<ActorMovieIMDB> bridges::DataSource::getActorMovieIMDBData2 ( )
inline

Get ActorMovie IMDB Data Data is retrieved, formatted into a list of ActorMovieIMDB objects.

Exceptions
Exceptionif the request fails
Returns
a list of ActorMovieIMDB objects, consisting of actor name, movie name, movie genre and movie rating is returned.

◆ getAmenityData() [1/2]

void bridges::DataSource::getAmenityData ( double  minLat,
double  minLon,
double  maxLat,
double  maxLon,
std::string  amenity 
)
inline

◆ getAmenityData() [2/2]

void bridges::DataSource::getAmenityData ( const std::string &  location,
const std::string &  amenity 
)
inline

◆ getCancerIncidenceData()

vector<CancerIncidence> bridges::DataSource::getCancerIncidenceData ( int  num = 0)
inline

Retrieves the CDC dataset of Cancer Incidence. Data is retrieved into a vector of records See CancerIncidence class for more information.

◆ getColorGridFromAssignment()

bridges::ColorGrid bridges::DataSource::getColorGridFromAssignment ( const std::string &  user,
int  assignment,
int  subassignment = 0 
)
inline

Reconstruct a ColorGrid from an existing ColorGrid on the Bridges server

Returns
the ColorGrid stored in the bridges server
Parameters
userthe name of the user who uploaded the assignment
assignmentthe ID of the assignment to get
subassignmentthe ID of the subassignment to get

◆ getEarthquakeUSGSData()

vector<EarthquakeUSGS> bridges::DataSource::getEarthquakeUSGSData ( int  number = 0)
inline

Get USGS earthquake data USGS Tweet data (https://earthquake.usgs.gov/earthquakes/map/) retrieved, formatted into a list of EarthquakeUSGS objects.

Parameters
numberthe number of earthquake records retrieved, limited to 5000
Exceptions
Exceptionif the request fails
Returns
a list of earthquake records

◆ getElevationData()

ElevationData bridges::DataSource::getElevationData ( double  latitMin,
double  longitMin,
double  latitMax,
double  longitMax,
double  res = 0.0166 
)
inline

Returns ElevationData for the provided coordinate box at the given resolution. Note that the ElevationData that is returned may have slightly different location and resolution.

Parameters
latitMinminimum latitude requested
longitMinmaximum latitude requested
latitMaxminimum longitude requested
longitMaxmaximum longitude requested
resspatial resolution, aka the distance between two samples (in degrees)

◆ getElevationDataFromJSON()

ElevationData bridges::DataSource::getElevationDataFromJSON ( string  elev_json)
inline

◆ getGameData()

vector<Game> bridges::DataSource::getGameData ( )
inline

Get meta data of the IGN games collection.

This function retrieves and formats the data into a list of Game objects

Exceptions
Exceptionif the request fails
Returns
a list of Game objects,

◆ getGraphFromAssignment()

bridges::GraphAdjList<int, std::string> bridges::DataSource::getGraphFromAssignment ( const std::string &  user,
int  assignment,
int  subassignment = 0 
)
inline

old interface for the OSM data set.

This is hitting a simpler API that has only a few map in there: "uncc_campus", "charlotte", "washington_dc", "saint_paul", "new_york", "los_angeles", "san_francisco", "miami", "minneapolis", "dallas"

Parameters
locationwhich location to get the map from OSMData getOSMDataOld (string location) { std::transform(location.begin(), location.end(), location.begin(), ::tolower); std::string osm_json; bool from_cache = false; try { if (my_cache.inCache(location)) { osm_json = my_cache.getDoc(location); from_cache = true; } } catch (CacheException& ce) { something went bad trying to access the cache std::cout << "Exception while reading from cache. Ignoring cache and continue." << std::endl; }

string url = string("http://osm-api.herokuapp.com/name/") + location;

if (!from_cache) { get the OSM data json osm_json = ServerComm::makeRequest(url, {"Accept: application/json"});

try { my_cache.putDoc(location, osm_json); } catch (CacheException& ce) { something went bad trying to access the cache std::cerr << "Exception while storing in cache. Weird but not critical." << std::endl; } }

return getOSMDataFromJSON(osm_json);

} Reconstruct a GraphAdjList from an existing GraphAdjList on the Bridges server

The reconstructed assignment sees vertices identified as integers in the order they are stored in the server. The data associated with a vertex is a string that comes from the label of that vertices. The data associated with an edge is the string that comes from the label of that edge. The edge weights are also reobtained from the bridges server.

Parameters
userthe name of the user who uploaded the assignment
assignmentthe ID of the assignment to get
subassignmentthe ID of the subassignment to get
Returns
the ColorGrid stored in the bridges server

◆ getGutenbergBookData()

vector<GutenbergBook> bridges::DataSource::getGutenbergBookData ( int  num = 0)
inline

Get meta data of the Gutenberg book collection. This function retrieves, and formats the data into a list of GutenbergBook objects.

Exceptions
Exceptionif the request fails
Returns
a list of GutenbergBook objects,

◆ getOSMData() [1/2]

OSMData bridges::DataSource::getOSMData ( double  lat_min,
double  long_min,
double  lat_max,
double  long_max,
string  level = "default" 
)
inline

Get OpenStreetMap data given a bounding rectangle of lat/long values.

Parameters
lat_minlatitude minimum
long_minlongitude minimum
lat_maxlatitude maximum
long_maxlongitude maximum
leveldata resolution
Exceptions
Exceptionif the request fails
Returns
an OSMData object

◆ getOSMData() [2/2]

OSMData bridges::DataSource::getOSMData ( string  location,
string  level = "default" 
)
inline

Get OpenStreetMap data given a city name and resolution level

Parameters
locationlocation name (string)
leveldata resolution
Exceptions
Exceptionif the request fails
Returns
an OSMData object

◆ getOSMDataFromJSON()

OSMData bridges::DataSource::getOSMDataFromJSON ( const string &  osm_json)
inline

Retrieves the Open Street Map data from a prebuilt JSON of OSM dataset.

Parameters
osm_jsonJSON string

◆ getShakespeareData()

vector<Shakespeare> bridges::DataSource::getShakespeareData ( string  type = "",
bool  textonly = false 
)
inline

Get data of Shakespeare works (plays, poems)

This function retrieves and formats the data into a a list of Shakespeare objects.

Exceptions
Exceptionif the request fails
Parameters
typecan be "plays", "poems", or "". If this is specified, then only these types of works are retrieved.
textonlyif this is set, then only the text is retrieved. (that is to say punctuation is stripped out)
Returns
an array of Shakespeare objects

◆ getSong()

Song bridges::DataSource::getSong ( string  songTitle,
string  artistName 
)
inline

Get data of a particular songs (including lyrics) using the Genius API (https://docs.genius.com/), given the song title and artist name. Valid endpoints: http://bridgesdata.herokuapp.com/api/songs/find/ Valid queryParams: song title, artist name.

This function retrieves and formats the data into a Song object. The song if not cached in the local DB is queried and added to the DB

Exceptions
Exceptionif the request fails
Returns
a Song object,

◆ getSongData()

vector<Song> bridges::DataSource::getSongData ( )
inline

Get data of the songs (including lyrics) using the Genius API https://docs.genius.com/ Valid endpoints: https://bridgesdata.herokuapp.com/api/songs/.

This function retrieves and formats the data into a list of Song objects. This version of the API retrieves all the cached songs in the local DB.

Exceptions
Exceptionif the request fails
Returns
a list of Song objects,

◆ getWikidataActorMovie()

std::vector<MovieActorWikidata> bridges::DataSource::getWikidataActorMovie ( int  yearbegin,
int  yearend 
)
inline

This function returns the Movie and Actors playing in them between two years.

Return movie pair in the [yearbegin; yearend] interval.

Parameters
yearbeginfirst year to include
yearendlast year to include

The documentation for this class was generated from the following file: