Commit 487eaa6d authored by jml's avatar jml
Browse files

replace res <- by an empty data.frame

parent 7b236e03
......@@ -16,10 +16,12 @@ get_short_meta_element <- function(frostObj,elements) {
stnr <-gsub(":.*","",tmp[,"sourceId"])
df <- data.frame(ID = stnr,CO_NAME = tmp[,"elementId"])
res <- rbind(res,df)
} else {
res <- data.frame(ID = character(0),CO_NAME=character(0))
}
}
} else {
res <- NULL
res <- data.frame(ID = character(0),CO_NAME=character(0))
}
return(unique(res))
}
......@@ -38,12 +40,14 @@ get_short_meta_element <- function(frostObj,elements) {
get_short_meta_station <- function(frostObj,stations=NULL,west=NULL,south=NULL,east=NULL,north=NULL) {
if (!is.null(stations)) {
res <- data.frame(ALT= numeric(0), LON= numeric(0), NAME = character(0), ID = character(0))
res <- data.frame(ALT= numeric(0), LAT= numeric(0), LON= numeric(0), NAME = character(0), ID = character(0))
for ( i in 1:length(stations)) {
tmp <- frostObj$getSources(ids=stations[i],format='jsonld')
if(!is.null(tmp)) {
df <- short_meta_df(tmp=tmp,indice=1)
res <- rbind(res,df)
} else {
res <- data.frame(ALT= numeric(0), LAT= numeric(0), LON= numeric(0), NAME = character(0), ID = character(0))
}
}
} else if ((!is.null(west)) && (!is.null(south)) && (!is.null(east)) && (!is.null(north))){
......@@ -51,18 +55,18 @@ get_short_meta_station <- function(frostObj,stations=NULL,west=NULL,south=NULL,e
tmp <- frostObj$getSources(type="SensorSystem",geometry=geom,format='jsonld')
if(!is.null(tmp)) {
nbs <- tmp$totalItemCount
res <- data.frame(ALT= numeric(0), LON= numeric(0), NAME = character(0), ID = character(0))
res <- data.frame(ALT= numeric(0), LAT= numeric(0), LON= numeric(0), NAME = character(0), ID = character(0))
for ( i in 1:nbs) {
df <- short_meta_df(tmp=tmp,indice=i)
res <- rbind(res,df)
}
} else {
res <- NULL
res <- data.frame(ALT= numeric(0), LAT= numeric(0), LON= numeric(0), NAME = character(0), ID = character(0))
}
} else {
res <- NULL
res <- data.frame(ALT= numeric(0), LAT= numeric(0), LON= numeric(0), NAME = character(0), ID = character(0))
}
return(res)
......@@ -87,7 +91,7 @@ get_short_meta_station_with_element <- function(frostObj,stations=NULL,west=NULL
if (!is.null(ele_meta) && !is.null(stn_meta)) {
res <- dplyr::inner_join(stn_meta,ele_meta)
} else {
res <- NULL
res <- data.frame(ID = character(0), CO_NAME=character(0), ALT= numeric(0), LAT= numeric(0), LON= numeric(0), NAME = character(0))
}
return(res)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment