Skip to content

Commit

Permalink
check that layer is actually in XML for better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
bwcompton committed Jan 9, 2024
1 parent 3014921 commit 1dce39e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/layer.info.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#' info <- layer.info(xml, 'DEPMEP:streams')
#'
# B. Compton, 12-14 and 29 Jun 2023
# 8 Jan 2024: check to make sure layer exists



Expand All @@ -45,6 +46,9 @@
x <- xml_children((xml_find_first(xml, paste0("//Layer[ows:Identifier = '", layer, "']/ows:WGS84BoundingBox"))))
box <- unlist(lapply(strsplit(xml_text(x), ' '), as.numeric))

if(length(xml_find_all(xml, paste0('//Layer[ows:Identifier = \'', layer, '\']'))) == 0)
stop('Error in readMVT: layer ', layer, ' is missing')

# get rows and cols for each zoom level
x <- xml_find_all(xml, paste0('//Layer[ows:Identifier = \'', layer, '\']//TileMatrixSetLink[TileMatrixSet = \'', crs, '\']//TileMatrixLimits'))
z <- data.frame(matrix(NA, length(x), 5)) # columns are Tile Matrix, min row, max row, min col, max col
Expand Down

0 comments on commit 1dce39e

Please sign in to comment.