From e06b68bd34fbff1adedcc2b7f7dc310c991fbf64 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Tue, 28 Jan 2020 22:36:58 +0000 Subject: [PATCH 01/12] Upversioned to 0.1.1-SNAPSHOT --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index a18d6b7..bc0b0f7 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject geocsv "0.1.0" +(defproject geocsv "0.1.1-SNAPSHOT" :description "A wee tool to show comma-separated value data on a map." :url "http://example.com/FIXME" From b25a71c4b4f8c929138cc340b6871c17ae51f103 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Wed, 29 Jan 2020 11:45:31 +0000 Subject: [PATCH 02/12] Updated README and docs --- README.md | 2 +- resources/docs/docs.md | 46 ++++++++++++++++------------------ src/cljs/geocsv/views/map.cljs | 7 ------ 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 2e12b74..34f9e16 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # geocsv -GeoCSV is a wee tool to show comma-separated value data on a map. +A wee tool to show comma-separated value data on a map. The CSV file must have diff --git a/resources/docs/docs.md b/resources/docs/docs.md index af49f3d..34f9e16 100644 --- a/resources/docs/docs.md +++ b/resources/docs/docs.md @@ -1,6 +1,6 @@ # geocsv -GeoCSV is a wee tool to show comma-separated value data on a map. +A wee tool to show comma-separated value data on a map. The CSV file must have @@ -12,14 +12,30 @@ The CSV file must have Additionally, the value of the column `category`, if present, will be used to select map pins from the map pins folder, if a suitable pin is present. Thus is the value of `category` is `foo`, a map pin image with the name `Foo-pin.png` will be selected. +## Passing CSV files to the app + +### Loading them onto the server + +If you run the server running **geocsv**, the simplest way to add CSV files is simply to copy them into the directory `resourcs/data`. The default file is the one named `data.csv`, which is the one that will be served if nothing else is specified. Other files can be specifiec by appending `?file=filename` to the URL; so if the URL of your geocsv service is + + https://geocsv.example.com/ + +and the file you want to view is `myfile.csv`, then you would specify this as + + https://geocsv.example.com/?file=myfile.csv + +### Using a Google spreadsheet + +If you use [Google Sheets](https://www.google.co.uk/sheets/about/), then every sheet has a 'document id', a long string of characters which uniquely identifies that sheet. Suppose your Google spreadsheet has a document id of `abcdefghijklmnopqrstuvwxyz-12345`, then you could pull data from this spreadsheet by specifying: + + https://geocsv.example.com/?docid=abcdefghijklmnopqrstuvwxyz-12345 + +The spreadsheet **must** be publicly readable. + ## Not yet working GeoCSV is at an early stage of development, and some features are not yet working. -### Doesn't actually interpret CSV - -I haven't yet found an easy way to parse CSV into EDN client side, so I've written a [separate library](https://github.com/simon-brooke/csv2edn) to do it server side. However, that library is not yet integrated. Currently the client side actually interprets JSON. - ### Missing map pin images At the current stage of development, if no appropriate image exists in the `resources/public/img/map-pins` folder, that's your problem. **TODO:** I intend at some point to make missing pin images default to `unknown-pin.png`, which does exist. @@ -28,26 +44,6 @@ At the current stage of development, if no appropriate image exists in the `reso Currently the map is initially centred roughly on the centre of Scotland, and scaled arbitrarily. It should compute an appropriate centre and scale from the data provided, but currently doesn't. -### There's no way of linking your own data feed - -Currently, the data is taken from the file `resources/public/data/data.json`. What I intend is that you should have a form which allows you to either - -1. enter [the `DOCID` of your own (publicly readable) Google Sheets spreadsheet](https://stackoverflow.com/questions/33713084/download-link-for-google-spreadsheets-csv-export-with-multiple-sheets); -2. enter the URL of a CSV file publicly available on the web; -3. upload a CSV file to the server. - -### There's no way of shareing the map of your own data with other people - -Currently, the data that is shared is just the data that's present when the app is compiled. Ideally, there should be a way of generating a URL, which might take the form: - - https://server.name/geocsv/docid/564747867 - -To show data from the first sheet of the Google Sheets spreadsheet whose `DOCID` is 564747867; or - - https://server.name/geocsv?uri=https://address.of.another.server/path/to/csv-file.csv - -to show the content of a publicly available CSV file. - ## Prerequisites You will need [Leiningen][1] 2.0 or above installed. diff --git a/src/cljs/geocsv/views/map.cljs b/src/cljs/geocsv/views/map.cljs index 8d9d3b5..e4f4329 100644 --- a/src/cljs/geocsv/views/map.cljs +++ b/src/cljs/geocsv/views/map.cljs @@ -70,13 +70,6 @@ :maxZoom 18})) view) (dispatch-sync [:set-view view]) -;; (.on view "moveend" -;; (fn [_] (let [c (.getCenter view)] -;; (js/console.log (str "Moving centre to " c)) -;; (dispatch-sync [:set-latitude (.-lat c)]) -;; (dispatch-sync [:set-longitude (.-lng c)]) -;; (dispatch [:fetch-data])))) -;; (refresh-map-pins) view)) (defn map-did-mount From a01cca0a654e30c208570df6137f7307e47eea04 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Wed, 29 Jan 2020 11:55:48 +0000 Subject: [PATCH 03/12] Getting map pins working; working around (not solving) resource bug/ --- package-lock.json | 13 - project.clj | 7 +- resources/html/error.html | 2 +- resources/html/home.html | 4 +- resources/public/css/screen.css | 8 +- .../lib/node_modules/leaflet/dist/leaflet.css | 636 ------------------ resources/public/js/package-lock.json | 3 + src/clj/geocsv/handler.clj | 4 +- src/clj/geocsv/routes/resources.clj | 14 + src/cljs/geocsv/core.cljs | 1 + src/cljs/geocsv/events.cljs | 29 + src/cljs/geocsv/gis.cljs | 70 +- 12 files changed, 101 insertions(+), 690 deletions(-) delete mode 100644 package-lock.json delete mode 100644 resources/public/js/lib/node_modules/leaflet/dist/leaflet.css create mode 100644 resources/public/js/package-lock.json create mode 100644 src/clj/geocsv/routes/resources.clj diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index a16f310..0000000 --- a/package-lock.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "geocsv", - "version": "0.1.0-SNAPSHOT", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "leaflet": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.3.1.tgz", - "integrity": "sha512-adQOIzh+bfdridLM1xIgJ9VnJbAUY3wqs/ueF+ITla+PLQ1z47USdBKUf+iD9FuUA8RtlT6j6hZBfZoA6mW+XQ==" - } - } -} diff --git a/project.clj b/project.clj index bc0b0f7..fa8b919 100644 --- a/project.clj +++ b/project.clj @@ -13,7 +13,7 @@ [com.cognitect/transit-clj "0.8.319"] [compojure "1.6.1"] [cprop "0.1.15"] - [csv2edn "0.1.5"] + [csv2edn "0.1.6"] [day8.re-frame/http-fx "0.1.6"] [expound "0.8.3"] [funcool/struct "1.4.0"] @@ -43,7 +43,10 @@ [selmer "1.12.18"]] :min-lein-version "2.0.0" - :npm {:dependencies [[leaflet "1.3.1"]]} + :npm {:dependencies [[bulma "0.8.0"] + [leaflet "1.3.1"] + [material-design-icons "3.0.1"]] + :root "resources/public/js/lib/node_modules"} :source-paths ["src/clj" "src/cljs" "src/cljc"] :test-paths ["test/clj"] diff --git a/resources/html/error.html b/resources/html/error.html index fd31cc5..88103f7 100644 --- a/resources/html/error.html +++ b/resources/html/error.html @@ -4,7 +4,7 @@ Something Bad Happened - {% style "/assets/bulma/css/bulma.min.css" %} + {% style "/js/lib/node_modules/bulma/css/bulma.min.css" %}