Skip to content

Commit

Permalink
[#3162] Use persistent view on data-groups map geo-point
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrammer committed Nov 29, 2021
1 parent eb8cd13 commit b70d654
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 6 additions & 8 deletions backend/src/akvo/lumen/lib/visualisation/map_config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
shape-table-name)))

(defn point-sql [tenant-conn columns geom-column popup-columns
point-color-column where-clause {:keys [datasetId] :as layer}]
point-color-column where-clause {:keys [datasetId tableName] :as layer}]
(let [{:keys [table-name columns]} (db.dataset/dataset-by-id tenant-conn {:id datasetId})
date-column-set (reduce (fn [m {:strs [columnName type]}]
(if (= "date" type) (conj m columnName) m))
Expand All @@ -246,7 +246,7 @@
point-color-column (conj (str (sql-option-bucket-column point-color-column) " as " (:columnName point-color-column)))))]
(format "select %s from %s where %s"
(str/join ", " cols)
table-name
(or tableName table-name)
where-clause)))

(defn shape-sql [tenant-conn columns geom-column popup-columns point-color-column where-clause
Expand Down Expand Up @@ -322,8 +322,8 @@
(or end-color "#000000")))

(defn- get-layers [tenant-conn layers metadata-array]
(map-indexed (fn [idx {:keys [datasetId rasterId filters geom popup pointColorColumn]
:as layer}]
(map (fn [idx {:keys [datasetId rasterId filters geom popup pointColorColumn]
:as layer} metadata]
(if (= (:layerType layer) "raster")
(let [{:keys [raster_table metadata]} (db.raster/raster-by-id tenant-conn {:id (:rasterId layer)})]
{:type "mapnik"
Expand All @@ -342,17 +342,15 @@
point-color-column (find-column kw-columns pointColorColumn)
sql (get-sql tenant-conn columns geom-column
popup-columns point-color-column
where-clause layer idx)]


where-clause (assoc layer :tableName (:tableName metadata)) idx)]
{:type "mapnik"
:options {:cartocss (trim-css (cartocss layer idx metadata-array))
:cartocss_version "2.0.0"
:geom_column (or geom "latlong")
:interactivity (get-interactivity layer popup-columns)
:sql sql
:srid "4326"}})))
layers))
(range) layers metadata-array))

(defn build [tenant-conn layers metadata-array]
{:version "1.6.0"
Expand Down
3 changes: 2 additions & 1 deletion backend/src/akvo/lumen/lib/visualisation/map_metadata.clj
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@

(defn point-metadata [tenant-conn table-name layer where-clause opts]
(let [column-titles (get-column-titles tenant-conn "table_name" table-name "main" (:datasetId layer))]
{:boundingBox (bounds tenant-conn table-name layer where-clause opts)
{:tableName table-name
:boundingBox (bounds tenant-conn table-name layer where-clause opts)
:pointColorMapping (point-color-mapping tenant-conn table-name layer where-clause column-titles)
:availableColors palette
:pointColorMappingTitle (get-column-title-for-name column-titles (:pointColorColumn layer))
Expand Down

0 comments on commit b70d654

Please sign in to comment.