Skip to content

Commit b0e794e

Browse files
committed
#401 gemet vocab implementation
1 parent 430e6f4 commit b0e794e

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

DESCRIPTION

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ Imports:
4545
mime,
4646
digest,
4747
dplyr,
48-
plyr,
4948
readr,
5049
arrow,
5150
zip,

NAMESPACE

-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ import(jsonlite)
118118
import(methods)
119119
import(mime)
120120
import(ows4R)
121-
import(plyr)
122121
import(readr)
123122
import(sf)
124123
import(sfarrow)

R/geoflow.R

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
#' @import httr
2525
#' @import mime
2626
#' @import jsonlite
27-
#' @import dplyr
2827
#' @import yaml
2928
#' @import XML
3029
#' @import xml2
3130
#' @import mime
32-
#' @import plyr
31+
#' @import dplyr
3332
#' @import readr
3433
#' @import arrow
3534
#' @import sf

R/geoflow_entity.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ geoflow_entity <- R6Class("geoflow_entity",
20592059
#'@return a list of \code{geoflow_contact} or a \code{data.frame}
20602060
getContacts = function(pretty = FALSE){
20612061
if(pretty){
2062-
out <- do.call("rbind.fill", lapply(self$contacts, function(contact){
2062+
out <- do.call(dplyr::bind_rows, lapply(self$contacts, function(contact){
20632063
contact.df <- data.frame(
20642064
id = contact$id,
20652065
stringsAsFactors = FALSE
@@ -2095,7 +2095,7 @@ geoflow_entity <- R6Class("geoflow_entity",
20952095
#'@return a list of \code{geoflow_subject} or a \code{data.frame}
20962096
getSubjects = function(pretty = FALSE, keywords = FALSE){
20972097
if(pretty){
2098-
out <- do.call("rbind.fill", lapply(self$subjects, function(subject){
2098+
out <- do.call(dplyr::bind_rows, lapply(self$subjects, function(subject){
20992099
subject.df <- data.frame(
21002100
subject_name = subject$name,
21012101
subject_uri = ifelse(is.null(subject$uri),NA,subject$uri),
@@ -2124,7 +2124,7 @@ geoflow_entity <- R6Class("geoflow_entity",
21242124
#'@return a list of \code{geoflow_relation} or a \code{data.frame}
21252125
getRelations = function(pretty = FALSE){
21262126
if(pretty){
2127-
out <- do.call("rbind.fill", lapply(self$relations, function(relation){
2127+
out <- do.call(dplyr::bind_rows, lapply(self$relations, function(relation){
21282128
relation.df <- data.frame(
21292129
key = relation$key,
21302130
stringsAsFactors = FALSE

R/geoflow_vocabulary.R

+15-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ geoflow_skos_vocabulary <- R6Class("geoflow_skos_vocabulary",
201201
}
202202
ORDER BY ?concept
203203
")
204-
self$query(str = str, mimetype = mimetype)
204+
self$query(str = str, mimetype = "text/csv")
205205
},
206206
"R" = {
207207
filter_by_language <- function(df, language) {
@@ -219,7 +219,7 @@ geoflow_skos_vocabulary <- R6Class("geoflow_skos_vocabulary",
219219
mimetype = "text/csv"
220220
)
221221
# Create a hierarchy data.frame
222-
sparql_result %>%
222+
out1 = sparql_result %>%
223223
dplyr::filter(p == "http://www.w3.org/2004/02/skos/core#broader") %>%
224224
dplyr::rename(concept = s, broaderConcept = o) %>%
225225
dplyr::select(concept, broaderConcept) %>%
@@ -232,6 +232,19 @@ geoflow_skos_vocabulary <- R6Class("geoflow_skos_vocabulary",
232232
by = "broaderConcept"
233233
) %>%
234234
dplyr::select(broaderConcept, broaderPrefLabel, concept, prefLabel)
235+
#add broader concepts as concepts for root
236+
out2 = do.call("rbind", lapply(unique(out1$broaderConcept), function(broaderConcept){
237+
res = NULL
238+
if(nrow(out1[out1$concept == broaderConcept,])==0){
239+
res = out1[out1$broaderConcept == broaderConcept,][1,]
240+
res$concept = res$broaderConcept
241+
res$prefLabel = res$broaderPrefLabel
242+
res$broaderConcept = NA
243+
res$broaderPrefLabel = NA
244+
}
245+
res
246+
}))
247+
rbind(out1,out2)
235248
}
236249
)
237250

0 commit comments

Comments
 (0)