R/sdd.R

Defines functions discovery getDataset main getDataFrame

discovery <- function(...){
  #TODO: How to introduce parameters from the user: space, time and theme
  resultSet <- SPARQL(endpoint, find_query)
}

getDataset <- function(ds){
  resultSet <- SPARQL(endpoint, find_query)
}

main <- function(...){
  #########################################################################################
  #01 - Function for retrieving datasets/datasources from the triple store
  #########################################################################################
  resultSet <- discovery()
  x <- cbind(resultSet[[1]][,"datasourceName"], resultSet[[1]][,"beginning"], resultSet[[1]][,"end"])
  colnames(x) <- c("datasourceName", "beginning", "end")
  print(x)
  #########################################################################################
  #02 - The user choses a single data set
  #########################################################################################
  userSelection <- as.numeric(readline(prompt = "Please select a dataset: "))
  #TODO: Validate user input
  chosenOne <- resultSet[[1]][userSelection,]
  #########################################################################################
  #03 - Build objects
  #########################################################################################
  se <- spatialExtent(wkt = unlist(chosenOne["wkt"]), gml = "")
  origin <- "1970-01-01"
  from <- as.POSIXlt(unlist(chosenOne["beginning"]), origin = origin)
  to <- as.POSIXlt(unlist(chosenOne["end"]), origin = origin)
  te <- temporalExtent(from = from, to = to)
  #########################################################################################
  #04 - The user selects a fields specific datatype
  #########################################################################################
  print(specificDatatypes)
  userSelection <- as.numeric(readline(prompt = "Please select a data type: "))
  chosenDatatype <- specificDatatypes[userSelection]
  #TODO: Validate user input
  #########################################################################################
  #05 - The client retrieves a dataframe from the the data source
  #########################################################################################
  resultSet <- getDataFrame(dsDescription = chosenOne, temporalExtent = te, spatialExtent = se)
  
}


getDataFrame <- function(dsDescription, temporalExtent, spatialExtent){
  # This function brings a dataframe with the data
  rSucks <- unlist(dsDescription["datasourceType"])
  
  if(rSucks == "<http://giv-lodum.uni-muenster.de/resource/fdd#PostGIS>"){
    #user <-
    #password <-
    #TODO: get the connection parameters, query and return the data.frame
  #}else if(){
    
  }
  
  
  
}
jimjonesbr/sdd documentation built on May 19, 2019, 10:34 a.m.