rmaxent
rmaxent copied to clipboard
maxent_versions not working properly and get_maxent unable to unpack latest version (3.4.4)
maxent_versions function is not currently parsing archived releases list from GitHub properly because the page layout changed. I'm afraid I cannot spend more time on this now so I'll share what I have (still not great because it returns duplicated versions but otherwise seems to work):
maxent_versions <- function(include_beta=FALSE) {
u <- 'https://github.com/mrmaxent/Maxent/tree/master/ArchivedReleases'
v <- xml2::read_html(u) %>%
rvest::html_nodes(xpath = '//a[@href[contains(.,"/tree/master/ArchivedReleases")]]') %>% # Changed xpath here
rvest::html_text()
v <- v[-1] # Likely no longer needed
cfg <- httr::set_config(httr::config(ssl_verifypeer = 0L))
on.exit(httr::set_config(httr::config(cfg)))
u2 <- 'https://biodiversityinformatics.amnh.org/open_source/maxent/index.html'
v2 <- httr::GET(u2) %>%
httr::content(encoding='UTF-8') %>%
rvest::html_nodes(xpath='//*[@id="Form"]/h3[1]') %>%
rvest::html_text()
v2 <- gsub('^\\s*Current\\s+version\\s*|\\s*$', '', v2)
v <- c(v, v2)
v <- sort(v[v!=''])
if(!include_beta) grep('beta', v, invert=TRUE, value=TRUE) else v
}
With get_maxent given above issue the function downloads from biodiversityinformatics.amnh.org and the problem is that the jar file is not at the root of the ZIP file anymore (if ever), so in: https://github.com/johnbaums/rmaxent/blob/08d11039404c78824b7daaaa7e9e2df8527efad9/R/get_maxent.R#L41
fails because the files param should be files='maxent/maxent.jar'
(in reality the code should attempt locating the file recursively instead but I don't know how to do that)