Skip to content

Instantly share code, notes, and snippets.

@jsanz
Last active September 27, 2021 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsanz/594be49cb2d1d9a9b575fd2a4291bda3 to your computer and use it in GitHub Desktop.
Save jsanz/594be49cb2d1d9a9b575fd2a4291bda3 to your computer and use it in GitHub Desktop.
FOSS4G 2021: Kart workshop
workshop
.env

Kart workshop

Compose set up

How to run the image:

  • Build the image with docker-compose build
  • Test the image with docker-compose up
$ docker-compose up
Starting kart_foss4g_1 ... done
Attaching to kart_foss4g_1
foss4g_1  | Kart v0.10.4, Copyright (c) Kart Contributors
foss4g_1  | » GDAL v3.2.0; PROJ v6.3.0
foss4g_1  | » PyGit2 v1.3.0; Libgit2 v1.1.0; Git v2.29.2
foss4g_1  | » SQLAlchemy v1.4.11; pysqlite3 v2.6.0/v3.31.1; SpatiaLite v5.0.0; Libpq v10.0.12
foss4g_1  | » SpatialIndex v1.9.3
kart_foss4g_1 exited with code 0
  • Log into the image with docker-compose run foss4g bash and check the data is available
$ ogrinfo -summary workshop/linz-chatham-islands/building-points-topo.shp building-points-topo
INFO: Open of `workshop/linz-chatham-islands/building-points-topo.shp'
      using driver `ESRI Shapefile' successful.

Layer name: building-points-topo
Geometry: Point
Feature Count: 614
Extent: (-176.828360, -44.337398) - (-176.163149, -43.707973)
Layer SRS WKT:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["latitude",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["longitude",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    ID["EPSG",4326]]
Data axis to CRS axis mapping: 2,1
t50_fid: Integer (9.0)
status: String (8.0)
bldg_use: String (21.0)
name_ascii: String (75.0)
macronated: String (1.0)
name: String (75.0)

Notes

  • Initialize the repo kart init ./first

  • Importing data kart import ${shape_path}

  • Check status kart status

  • List datasets kart data ls

  • A new gpkg file is created

  • Add data to the gpkg with QGIS

  • Check the status kart status

  • Commit changes kart commit "new points"

  • Commit a single feature from a layer kart commit building-points-topo:feature:620 -m "single feature commit"

  • Restore to the last commit status kart restore

  • Checkout a specific commit kart checkout ${commit_id}

  • Go back to the last commit kart checkout main

  • Clone a repo kart clone kart@foss4g-2021.kartproject.org:second

  • Create a branch kart branch jsanz

  • Switch to a branch kart switch branch

  • Get diffs with a branch:

    • Simple kart diff main..
    • As JSON kart diff main.. -o json
    • As HTML kart diff main.. -o html --crs "EPSG:4326"
    • Just the feature count kart diff main.. --only-feature-count exact
  • Merge conflicts with our changes kart resolve --with ours island-polygons-topo:feature:178

version: '3.7'
services:
foss4g:
build:
context: .
volumes:
- ./workshop:/home/foss4g/workshop
- ${SECRET_KEY}:/home/foss4g/.ssh/id_rsa
- ${PUBLIC_KEY}:/home/foss4g/.ssh/id_rsa.pub
networks:
- foss4g
networks:
foss4g:
name: foss4g
FROM debian:bullseye-slim as foss4g
USER root
# Prepare the image with some usual tools
RUN bash -c "set -eux ;\
apt-get -qq update ;\
DEBIAN_FRONTEND=noninteractive apt-get -y install \
jq \
git \
vim \
tree \
curl \
sudo \
unzip \
gdal-bin;\
useradd -ms /bin/bash foss4g;\
echo 'foss4g:foss4g' | chpasswd;\
usermod -aG sudo foss4g"
FROM foss4g as kart
# Kart installation
RUN bash -c "set -eux ;\
curl -Lo /tmp/kart.deb \
https://github.com/koordinates/kart/releases/download/v0.10.4/kart_0.10.4-1_amd64.deb; \
apt install -y /tmp/kart.deb"
USER foss4g
WORKDIR /home/foss4g
# Download data
RUN bash -c "set -eux ;\
mkdir -p /home/foss4g/workshop/;\
mkdir -p /home/foss4g/.ssh ;\
cd /home/foss4g/workshop/;\
curl -Lo data.zip http://foss4g-2021.kartproject.org/static/linz-chatham-islands.zip; \
unzip data.zip"
RUN bash -c "set -eux ;\
git config --global user.email \"nobody@nobody.co\";\
git config --global user.name \"FOSS4G Dummy user\""
CMD [ "kart", "--version" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment