Fork me on GitHub
#clojure-uk
<
2017-04-07
>
korny06:04:50

@malcolmsparks handy,but only for the specific example I was giving - actually I'm throwing together a script to collect git info, looking for ways to go from a list of remotes to a map of data about each remote. It seemed a common task, I was surprised there wasn't a function for it.

peterwestmacott07:04:07

given the meaning of the word “map” it seems particularly surprising to me

peterwestmacott07:04:58

non-random core function of the day:

clojure.core/partition
([n coll] [n step coll] [n step pad coll])
  Returns a lazy sequence of lists of n items each, at offsets step
  apart. If step is not supplied, defaults to n, i.e. the partitions
  do not overlap. If a pad collection is supplied, use its elements as
  necessary to complete last partition upto n items. In case there are
  not enough padding elements, return a partition with less than n items.

agile_geek07:04:38

@peterwestmacott nice, but I find myself using partition-all more often as I'm breaking a sequence into 'chunks' but don't want to drop the last items on the floor.

peterwestmacott07:04:00

yes, partition has some useful variants

peterwestmacott07:04:04

you can also partition-all with transducers, which you can’t with partition

korny07:04:10

my random discovery: clojure.set/map-invert - inverts a map, swapping keys with values. No idea why it’s in clojure.set

korny07:04:44

Hmm - on the juxt emoji - I should probably remove it and let some of the juxt folks upload their own juxt logo or something 🙂

malcolmsparks08:04:37

I think there has to be a balance between having a core function for everything and a small composeable core lib. @reborg will tell you the core library isn't small any more...

dominicm08:04:25

@korny watch out when you have maps like:

{:foo 1
 :bar 1}

korny08:04:42

yeah, it’s not a function I’d use a lot! Really, that should be like group-by and return {1 [:foo :bar]} but it doesn’t.

peterwestmacott09:04:58

(group-by second {:foo 1 :bar 1}) gets you about half way there…

maleghast10:04:14

Slightly off-topic, but is there anyone on here who might be able to provide an early, early start-up technologist, say like me, a corner of an office in London Mon-Thurs next week..? Cheeky, I know, but we are not yet possessed of an office and while I will be meeting with my new colleagues for some of the time, for the rest I am going to need somewhere to actually get some work done...

maleghast10:04:05

There may be a chance we can pay you, but I am not expecting that will be simple... We will__ be prepared to pay it forward in the future, however...

maleghast10:04:56

And now a Clojure question... Does anyone have any ideas on where to start if looking for tools / libraries in Clojure for manipulating .shp (Shape) files?

otfrom10:04:35

I'd look at wrapping that for what you need

maleghast10:04:06

I may well do... I am also considering putting the shape files in question into PostgreSQL under postGIS and then talking to a DB, but I am keeping my options open, and was hoping__ for a library... Still if I have to build my own that will be a fun and educational experience...

maleghast11:04:18

@otfrom - I am reading around the subject, but this looks as though it might be helpful as well... https://github.com/factual/geo

rickmoynihan11:04:03

@maleghast: we’ve used http://www.geotools.org/ in the past… specifically the org.geotools/gt-shapefile package. I didn’t write the code on that project though, so not sure why it was chosen in preference to anything else… though geotools should be pretty comprehensive.

maleghast11:04:29

Thanks @rickmoynihan I will take a look.

mccraigmccraig17:04:52

@maleghast import that .shp into PostGIS and thereafter play with GeoJSON etc… i’ve done a tonne of geospatial stuff and PostGIS was always a most excellent starting point for import and normalization

maleghast17:04:20

@mccraigmccraig - Thanks... I was starting to feel that was going to be what I wanted, after an afternoon's research. Good to get some validation on that though, 🙂

mccraigmccraig17:04:40

unless you are lucky you are going to have to change the projection of at least some of your datasets - PostGIS makes that a bunch of SQL and is rock solid

maleghast17:04:42

I like the sound of that!

maleghast17:04:18

I am going to see if I can get postGIS installed on here with homebrew, or even Docker, perhaps...

mccraigmccraig17:04:10

i haven’t worked with postgresql/postgis for a while, but the homebrew install used to be fine

maleghast17:04:10

I'd rather get a Docker container for it if I possible can...

maleghast17:04:20

...although the tools to convert the shapefile into SQL need to be available to me. Hmmmm

mccraigmccraig17:04:02

@maleghast shp2psql here’s an example invocation i used for importing NUTS boundaries https://gist.github.com/40b1675f6eb01cd3fcd0cf41bf9cf168

mccraigmccraig17:04:33

oh, but i see what you mean - you will need to invoke shp2psql

maleghast18:04:03

I brew installed Postgres and the postgis

maleghast18:04:45

I have imported a shape file and am now using brew cask to install Qgis so I can test the DB quickly

maleghast19:04:27

And now I am reading the docs on postgis website trying to work out how I can possibly use the data I've added