Skip to content

Commit

Permalink
fix data layer issue, add buildings_poly to list including defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Oct 17, 2015
1 parent fc2a852 commit ba4fbf4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
12 changes: 7 additions & 5 deletions R/canvec.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ canvec.cachedir <- function() {
dirname
}


# Load canvec_layers into package namespace
#canvec_layers <- NULL #hack because data(canvec_layers) will load to variable
utils::data(canvec_layers, envir=environment())

# Functions to get file names --------

canvec.layers <- function(...) {
layerids <- list(...)
if(length(layerids)==0) stop("No arguments passed to canvec.layers()")

canvec_layers <- NULL #hack because data(canvec_layers) will load to variable
utils::data(canvec_layers, envir=environment())

filt <- match(layerids, canvec_layers$id)
if(any(is.na(filt))) {
stop("Could not find layer(s): ", paste(layerids[is.na(filt)], collapse=", "))
Expand Down Expand Up @@ -267,8 +269,6 @@ canvec.export <- function(ntsid, tofolder, layers=NULL, crs=NULL, cachedir=NULL,
cachedir <- canvec.cachedir()
}
if(is.null(layers)) {
canvec_layers <- NULL #hack because data(canvec_layers) will load to variable
utils::data(canvec_layers, envir=environment())
layers <- canvec_layers$id
}

Expand Down Expand Up @@ -488,6 +488,8 @@ canvec.defaultoptions <- function(layerid) {
return(list(col="black", lwd=0.5))
} else if(layerid=="forest") {
return(list(col=.makecol(208, 234, 221), border=.makecol(208, 234, 221)))
} else if(layerid=="building_poly") {
return(list(col="black", border="black"))
} else {
return(list())
}
Expand Down
12 changes: 6 additions & 6 deletions data-raw/canvec_layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#Define canvec layers data frame ----

canvec_layers <- structure(list(name = c("Navigational aid", "Residential area",
"Parabolic antenna", "Building", "Chimney", "Tank", "Cross",
"Parabolic antenna", "Building (point)", "Building (poly)", "Chimney", "Tank", "Cross",
"Transmission line", "Wall/fence", "Pipeline (Sewage/liquid waste)",
"Well", "Underground reservoir", "Silo", "Tower", "Power transmission line",
"Pipeline", "Valve", "Gas and oil facilities", "Transformer station",
Expand All @@ -27,7 +27,7 @@ canvec_layers <- structure(list(name = c("Navigational aid", "Residential area",
"Road segment", "Junction", "Blocked passage", "Toll point",
"Wooded area", "Cut line"),
id = c("navigational_aid", "residential_area",
"parabolic_antenna", "building", "chimney", "tank", "cross",
"parabolic_antenna", "building", "building_poly", "chimney", "tank", "cross",
"transmission_line", "wall_fence", "pipeline_sewage",
"well", "underground_reservoir", "silo", "tower", "power_transmission_line",
"pipeline", "valve", "gas_and_oil_facilities", "transformer_station",
Expand All @@ -50,7 +50,7 @@ canvec_layers <- structure(list(name = c("Navigational aid", "Residential area",
"rail_ferry", "railway_station", "runway", "ferry_connection_segment",
"road", "junction", "blocked_passage", "toll_point",
"forest", "cut_line"),
theme = c("bs", "bs", "bs", "bs",
theme = c("bs", "bs", "bs", "bs", "bs",
"bs", "bs", "bs", "bs", "bs", "bs", "bs", "bs", "bs", "bs", "en",
"en", "en", "en", "en", "en", "fo", "fo", "fo", "fo", "fo", "fo",
"fo", "fo", "fo", "fo", "fo", "hd", "hd", "hd", "hd", "hd", "hd",
Expand All @@ -60,7 +60,7 @@ canvec_layers <- structure(list(name = c("Navigational aid", "Residential area",
"lx", "lx", "lx", "lx", "lx", "lx", "lx", "ss", "ss", "ss", "ss",
"ss", "to", "tr", "tr", "tr", "tr", "tr", "tr", "tr", "tr", "tr",
"tr", "ve", "ve"),
filename = c("bs_1250009", "bs_1370009", "bs_2000009",
filename = c("bs_1250009", "bs_1370009", "bs_2000009", "bs_2010009",
"bs_2010009", "bs_2060009", "bs_2080009", "bs_2120009", "bs_2230009",
"bs_2240009", "bs_2310009", "bs_2350009", "bs_2380009", "bs_2440009",
"bs_2530009", "en_1120009", "en_1180009", "en_1340009", "en_1360049",
Expand All @@ -81,7 +81,7 @@ canvec_layers <- structure(list(name = c("Navigational aid", "Residential area",
"tr_1750009", "tr_1760009", "tr_1770009", "tr_1780009", "tr_1790009",
"ve_1240009", "ve_2290009"),
geometry = c("point", "polygon",
"point", "point", "point", "point", "point", "line", "line", "line",
"point", "point", "polygon", "point", "point", "point", "line", "line", "line",
"point", "point", "point", "point", "line", "line", "point",
"point", "point", "point", "line", "polygon", "line", "polygon",
"polygon", "polygon", "polygon", "point", "point", "line", "point",
Expand All @@ -97,6 +97,6 @@ canvec_layers <- structure(list(name = c("Navigational aid", "Residential area",
"polygon", "line")),
.Names = c("name", "id", "theme", "filename", "geometry"),
class = "data.frame",
row.names = c(NA, -95L))
row.names = c(NA, -96L))

canvec_layers$geometry_ext <- gsub("point", "_0", gsub("line", "_1", gsub("polygon", "_2", canvec_layers$geometry)))
Binary file modified data/canvec_layers.rda
Binary file not shown.

0 comments on commit ba4fbf4

Please sign in to comment.