edgarodriguez commited on
Commit
1a65f17
·
verified ·
1 Parent(s): fed2ea0

Upload depth_interactive_map_alpha.R

Browse files
Files changed (1) hide show
  1. depth_interactive_map_alpha.R +9 -27
depth_interactive_map_alpha.R CHANGED
@@ -454,14 +454,9 @@ WEB_SQL_TEMPLATES <- list(
454
  load_infra_pts =
455
  "SELECT row_number() OVER () AS row_id, lon, lat,
456
  CASE
457
- WHEN category = 'Shelter' THEN 'Shelter'
458
- WHEN LOWER(category) IN ('food','restaurant','lodging') THEN 'Food & Lodging'
459
- WHEN LOWER(category) = 'government' THEN 'Government'
460
- WHEN LOWER(category) = 'embassy' THEN 'Embassy'
461
- WHEN category = 'Legal/NGO' OR LOWER(category) = 'charity' THEN 'Legal & Aid'
462
- WHEN LOWER(category) = 'police' THEN 'Police'
463
- WHEN LOWER(category) IN ('hospital','medical') THEN 'Health'
464
- WHEN LOWER(category) IN ('religious','place-of-worship') THEN 'Religious'
465
  ELSE 'Other'
466
  END AS cat
467
  FROM support_infrastructure
@@ -676,14 +671,9 @@ WEB_SQL_TEMPLATES <- list(
676
  donut_infra =
677
  "SELECT
678
  CASE
679
- WHEN category = 'Shelter' THEN 'Shelter'
680
- WHEN LOWER(category) IN ('food','restaurant','lodging') THEN 'Food & Lodging'
681
- WHEN LOWER(category) = 'government' THEN 'Government'
682
- WHEN LOWER(category) = 'embassy' THEN 'Embassy'
683
- WHEN category = 'Legal/NGO' OR LOWER(category) = 'charity' THEN 'Legal & Aid'
684
- WHEN LOWER(category) = 'police' THEN 'Police'
685
- WHEN LOWER(category) IN ('hospital','medical') THEN 'Health'
686
- WHEN LOWER(category) IN ('religious','place-of-worship') THEN 'Religious'
687
  ELSE 'Other'
688
  END AS cat,
689
  COUNT(*) AS n
@@ -3410,17 +3400,9 @@ server <- function(input, output, session) {
3410
  # the legend (mirrors the SQL CASE in WEB_SQL_TEMPLATES$load_infra_pts).
3411
  normalize_infra_cat <- function(category) {
3412
  if (length(category) == 0) return(character(0))
3413
- c_low <- tolower(category)
3414
- out <- ifelse(category == "Shelter", "Shelter",
3415
- ifelse(c_low %in% c("food","restaurant","lodging"), "Food & Lodging",
3416
- ifelse(c_low == "government", "Government",
3417
- ifelse(c_low == "embassy", "Embassy",
3418
- ifelse(category == "Legal/NGO" | c_low == "charity", "Legal & Aid",
3419
- ifelse(c_low == "police", "Police",
3420
- ifelse(c_low %in% c("hospital","medical"), "Health",
3421
- ifelse(c_low %in% c("religious","place-of-worship"), "Religious",
3422
- "Other"))))))))
3423
- out
3424
  }
3425
 
3426
  # Quantile-break cache: pre-populated from the app-level cache (loaded at startup).
 
454
  load_infra_pts =
455
  "SELECT row_number() OVER () AS row_id, lon, lat,
456
  CASE
457
+ WHEN category IN ('Shelter', 'Support (NGO)', 'Support (GOV)',
458
+ 'Migration office', 'Embassy / Consulate')
459
+ THEN category
 
 
 
 
 
460
  ELSE 'Other'
461
  END AS cat
462
  FROM support_infrastructure
 
671
  donut_infra =
672
  "SELECT
673
  CASE
674
+ WHEN category IN ('Shelter', 'Support (NGO)', 'Support (GOV)',
675
+ 'Migration office', 'Embassy / Consulate')
676
+ THEN category
 
 
 
 
 
677
  ELSE 'Other'
678
  END AS cat,
679
  COUNT(*) AS n
 
3400
  # the legend (mirrors the SQL CASE in WEB_SQL_TEMPLATES$load_infra_pts).
3401
  normalize_infra_cat <- function(category) {
3402
  if (length(category) == 0) return(character(0))
3403
+ known <- c("Shelter", "Support (NGO)", "Support (GOV)",
3404
+ "Migration office", "Embassy / Consulate")
3405
+ ifelse(category %in% known, category, "Other")
 
 
 
 
 
 
 
 
3406
  }
3407
 
3408
  # Quantile-break cache: pre-populated from the app-level cache (loaded at startup).