Bridges-C++
3.4.4
Bridges(C++ API)
|
#include <DataSource.h>
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.
Outputs more information if the environment variable FORCE_BRIDGES_DATADEBUG exists, regardless of what it is set too.
Public Member Functions | |
DataSource (bridges::Bridges *br=nullptr) | |
DataSource (bridges::Bridges &br) | |
void | setSourceType (string type) |
set data server type More... | |
vector< City > | getUSCities (unordered_map< string, string > params) |
Retrieves US city data based on a set of filtering parameters. More... | |
vector< Game > | getGameData () |
Get meta data of the IGN games collection. More... | |
vector< ActorMovieIMDB > | getActorMovieIMDBData (int number=0) |
Get ActorMovie IMDB Data Data is retrieved, formatted into a list of ActorMovieIMDB objects. More... | |
vector< ActorMovieIMDB > | getActorMovieIMDBData2 () |
Get ActorMovie IMDB Data Data is retrieved, formatted into a list of ActorMovieIMDB objects. More... | |
vector< EarthquakeUSGS > | getEarthquakeUSGSData (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< Shakespeare > | getShakespeareData (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< Song > | getSongData () |
Get data of the songs (including lyrics) using the Genius API https://docs.genius.com/ Valid endpoints: https://bridgesdata.herokuapp.com/api/songs/. More... | |
GutenbergBook | getGutenbergBookMetaData (int id=0) |
Get meta data of a single Gutenberg book This function retrieves, and formats the data into a list of GutenbergBook objects. More... | |
vector< GutenbergBook > | getGutenbergBookMetaData (string term, string category) |
Search the gutenberg data for retrieving meta data of books matching a string and a category. More... | |
string | getGutenbergBookText (int id=0) |
Get the full text of the book with the provided id. More... | |
vector< CancerIncidence > | getCancerIncidenceData (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 | 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... | |
vector< Amenity > | getAmenityData (double minLat, double minLon, double maxLat, double maxLon, std::string amenity) |
vector< Amenity > | getAmenityData (const std::string &location, const std::string &amenity) |
vector< Amenity > | parseAmenityData (string amenity_json) |
Parses the amenity string and returns an AmenityData object. More... | |
OSMData | getOSMData (string location, string level="default") |
bridges::GraphAdjList< int, std::string > | getGraphFromAssignment (const std::string &user, int assignment, int subassignment=0) |
bridges::ColorGrid | getColorGridFromAssignment (const std::string &user, int assignment, int subassignment=0) |
std::vector< MovieActorWikidata > | getWikidataActorMovie (int yearbegin, int yearend) |
This function returns the Movie and Actors playing in them between two years. More... | |
ElevationData | getElevationData (double minLat, double minLon, double maxLat, double maxLon, double res=0.0166) |
ElevationData | parseElevationData (string elev_json) |
Parses the elevation data string and retuns an Elevation object. More... | |
std::vector< std::string > | getAvailableSubreddits () |
retrieves the subreddits made available by BRIDGES More... | |
vector< Reddit > | getRedditData (string subreddit, int time_request=-9999) |
|
inline |
|
inline |
|
inline |
Get ActorMovie IMDB Data Data is retrieved, formatted into a list of ActorMovieIMDB objects.
number | the number of actor/movie pairs, but currently unused, returns all records. |
Exception | if the request fails |
|
inline |
Get ActorMovie IMDB Data Data is retrieved, formatted into a list of ActorMovieIMDB objects.
Exception | if the request fails |
|
inline |
This method retrieves the specified amenity related data given a location from a specified openstreet mmap location
location | city/town from where amenity data is sought |
amenity | amenity type |
exception |
|
inline |
This method retrieves the specified amenity related data given a bounding box of a region, from a Open Street map
minLat | minimum latitude |
minLon | minimumm longitude |
maxLat | maximum latitude |
maxLon | maximum longitude |
amenity | amenity type |
exception |
|
inline |
retrieves the subreddits made available by BRIDGES
|
inline |
Retrieves the CDC dataset of Cancer Incidence. Data is retrieved into a vector of records See CancerIncidence class for more information.
|
inline |
Reconstruct a ColorGrid from an existing ColorGrid on the Bridges server
user | the name of the user who uploaded the assignment |
assignment | the ID of the assignment to get |
subassignment | the ID of the subassignment to get |
|
inline |
Get USGS earthquake data USGS Tweet data (https://earthquake.usgs.gov/earthquakes/map/) retrieved, formatted into a list of EarthquakeUSGS objects.
number | the number of earthquake records retrieved, limited to 5000 |
Exception | if the request fails |
|
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.
latitMin | minimum latitude requested |
longitMin | maximum latitude requested |
latitMax | minimum longitude requested |
longitMax | maximum longitude requested |
res | spatial resolution, aka the distance between two samples (in degrees) |
|
inline |
Get meta data of the IGN games collection.
This function retrieves and formats the data into a list of Game objects
Exception | if the request fails |
|
inline |
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.
user | the name of the user who uploaded the assignment |
assignment | the ID of the assignment to get |
subassignment | the ID of the subassignment to get |
|
inline |
Get meta data of a single Gutenberg book This function retrieves, and formats the data into a list of GutenbergBook objects.
id | Gutenberg book id |
|
inline |
Search the gutenberg data for retrieving meta data of books matching a string and a category.
Data is retrieved into a vector of book records
term | a string that matches the category |
category | category can be any book attribute (title, genre, date, Library of Congress class, language) |
|
inline |
Get the full text of the book with the provided id.
Data is retrieved into a text string
id | id of Gutenberg book |
|
inline |
Get OpenStreetMap data given a bounding rectangle of lat/long values.
The function also take a level of detail which can be anything in ["motorway", "trunk", "primary", "secondary", "tertiary, "unclassified", "residential", "living_street", "service", "trails", "walking", "bicycle" ]
lat_min | latitude minimum |
long_min | longitude minimum |
lat_max | latitude maximum |
long_max | longitude maximum |
level | data resolution |
Exception | if the request fails |
|
inline |
Get OpenStreetMap data given a city name and resolution level
The function also take a level of detail which can be anything in ["motorway", "trunk", "primary", "secondary", "tertiary, "unclassified", "residential", "living_street", "service", "trails", "walking", "bicycle" ]
location | location name (string) |
level | data resolution |
Exception | if the request fails |
|
inline |
@brief retrieves the reddit posts from a subreddit
subreddit | the name of the subreddit ( check list available at http://bridges-data-server-reddit.bridgesuncc.org/list or using getAvailableSubreddits() ) |
time_request | unix timestamp of when requested subreddit was generated or less than 0 for now |
|
inline |
Get data of Shakespeare works (plays, poems)
This function retrieves and formats the data into a a list of Shakespeare objects.
Exception | if the request fails |
type | can be "plays", "poems", or "". If this is specified, then only these types of works are retrieved. |
textonly | if this is set, then only the text is retrieved. (that is to say punctuation is stripped out) |
|
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
songTitle | title of the song. inexact is ok, will be matched by genisu |
artistName | name of artist. empty string if unspecified. If specified, must be exact |
Exception | if the request fails |
|
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.
Exception | if the request fails |
|
inline |
Retrieves US city data based on a set of filtering parameters.
params | this represents a specification of the filtering parameters provided as a map. Multiple parameters will result in filtering as a combination (intersection) Available parameters and their types are as follows: 'city' : string 'state' : string 'country' : string 'time_zone' : string 'min_elev' : integer 'max_elev' : integer 'min_pop' : integer 'max_pop' : integer 'min_lat' : float – Lat minimum 'max_lat' : float – Lat maximum 'min_long' : float – Lat minimum 'max_long' : float – Lat maximum 'limit' : integer – max number of cities to return |
|
inline |
This function returns the Movie and Actors playing in them between two years.
Return movie pair in the [yearbegin; yearend] interval.
yearbegin | first year to include |
yearend | last year to include |
|
inline |
Parses the amenity string and returns an AmenityData object.
amenity_json | string of the url that will be used when requesting amenity data from server |
If | there is an error parsing response from server or is an invalid location name |
|
inline |
Parses the elevation data string and retuns an Elevation object.
elev_json | string containing the requested elevation data |
|
inline |
set data server type
string | data server type, can be 'live', 'testing', or 'local') |
exception | if incorrect type is passed |