lipas-liikuntapaikat / lipas

Lipas is a nationwide, public GIS service of Finnish sport and recreation facilities.
MIT License
70 stars 14 forks source link

Implementation of map for GIS #51

Closed zackteo closed 3 years ago

zackteo commented 4 years ago

Got here from your CLOJUTRE 2019 talk. Was particularly interested as I feel I'm in a position where you were at - just beginning learn Clojure and wanting to use it for work, except in my case it is for my (Final Year) Capstone project. And it happens to also be GIS related.

Anyway, isit just me or did you effectively implement your own clojure mapping library in this? I was thinking you would use something like Leaflet.js . Am trying to figure out how your web app works

vharmain commented 4 years ago

Hi @zackteo ! Sorry It took me a while to respond. If you look at the source code, I'm using OpenLayers (5.x) wrapped as a React-component with Reagent. In the early stages I experimented with Leaflet, which is much simpler, but also limited in features compared to OpenLayers.

Openlayers related code can be found under https://github.com/lipas-liikuntapaikat/lipas/tree/master/webapp/src/cljs/lipas/ui/map

Let me know if you want to discuss more about the GIS-functionality! I'm happy to help.

zackteo commented 4 years ago

Hi @vharmain ! No worries! Thanks for taking the time to respond, do appreciate it!

And thanks for linking me to the relevant code, will probably take awhile for me to understand the Codebase properly! Will ask if I need any clarification!

In the meantime, could I ask about what features caused you to make the switch from Leaflet to OpenLayers?

Also, not sure if you could provide any advice on how I would perhaps integrate Python or R related data science work into the stack? Friends will be exploring the optimising of land allocation in those languages and am thinking how I will bring it back into the web app if via the Backend. Not sure if the only way that might make sense is to rewrite the logic in Clojure (+PostGIS if needed)?

Thanks for your help! Any help would be very much appreciated it! Am just trying to meander my way through this (And trying to ensure I have a good grasp of things - especially since I dragged 5 friends along for this Clojure journey/project) ><

vharmain commented 4 years ago

where I was exploring the possibility of swapping out the Leaflet code with ArcGIS JS app

Cool! I haven't done anything with ESRI products for many many years. I've been happy with OpenSource tools for a while but it would be nice to check at some point what ESRI is offering on the web-side nowadays.

what features caused you to make the switch from Leaflet to OpenLayers?

At least back then Leaflet geometry editing plug-in didn't support custom CRS that well and lacked features, such as splitting/joining linestrings and other fancier geometry editing tools. If I was creating an app just for displaying geometries, Leaflet would be fine though.. But in LIPAS the data producers must be able to also draw and edit the geometries and OpenLayers had pretty much everything built-in.

trying to figure out what mapping library I might require and how it would work with ClojureScript

The superpower with Clojure and ClojureScript is that everything that is supported by the underlying platform (JVM, JS) will work. What comes to ergonomics is of course another question. :) In my experience mapping libraries are highly imperative and stateful which makes working with them feel non-idiomatic in ClojureScript.

There are attempts to create a declarative (React) components for Leaflet (react-leaflet). I ended up doing something similar with OpenLayers. I wrapped the stateful and imperative bits behind a single React/Reagent component to which I just pass in a map of what I want it to look and do. This took some time and effort and it still looks and feels a bit like a kludge... But it has worked really well for me and it hasn't been too much pain to maintain.

Think I have settled on a more a tested and documented framework/libraries of Reframe + Reagent and think Ring + Pedestal.

Re-Frame and Reagent are bullet-proof choices if you're going to write a React app in ClojureScript. Ring in the backend is pretty much the standard. I have no experience in Pedestal but what I've heard and read, you can't go wrong with that either.

Also, not sure if you could provide any advice on how I would perhaps integrate Python or R related data science work into the stack?

It depends of course much on the nature of work that is done on the Python/R side. If they are scripts that just take inputs and produce outputs, you could call those scripts from the JVM directly. If Python/R stuff is just experimental and not "production ready" I'd consider rewriting them. GraalVM provides also an interesting alternative where you can run JVM, Python and R code within the same application.

Your project sounds interesting! I'm glad if my mumblings are helpful in some way. :) Let me know if you have any further questions.