-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTupfile
52 lines (41 loc) · 2.17 KB
/
Tupfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
NATURAL_EARTH_URL=https://raw.githubusercontent.com/nvkelso/natural-earth-vector/@(NATURAL_EARTH_COMMIT)/geojson
GEOBOUNDARIES_URL=https://github.com/wmgeolab/geoBoundaries/raw/@(GEOBOUNDARIES_COMMIT)/releaseData
DOWNLOAD_URI=https://github.com/SmilyOrg/tinygpkg-data/releases/download/@(RELEASE_TAG)/
# Convert any GDAL supported format to a valid GeoPackage gpkg file
!makevalid = |> cat %f | docker run --rm -i -w / ghcr.io/osgeo/gdal:alpine-normal-@(GDAL_VERSION) sh -c "cp /dev/stdin %b && ogr2ogr -makevalid -f "GPKG" out.gpkg %b && cat out.gpkg" > %o |> %B_makevalid.gpkg
# Required for Go builds
export GOPATH
export GOCACHE
export LocalAppData
# Executable extension
ifeq (@(TUP_PLATFORM),win32)
EXE = .exe
else
EXE =
endif
# Build simplify tool
simplify=simplify$(EXE)
: |> go build ./cmd/simplify |> $(simplify) ^.*/go-build/.*
# Build tgpkg tool (compress to tinywkb and back)
tgpkg=tgpkg$(EXE)
: |> go build ./cmd/tgpkg |> $(tgpkg) ^.*/go-build/.*
# Download datasets
: |> curl -L $(NATURAL_EARTH_URL)/ne_110m_admin_0_countries.geojson -o %o |> data/ne_110m_admin_0_countries.geojson
: |> curl -L $(NATURAL_EARTH_URL)/ne_10m_admin_0_countries.geojson -o %o |> data/ne_10m_admin_0_countries.geojson
: |> curl -L $(NATURAL_EARTH_URL)/ne_10m_urban_areas_landscan.geojson -o %o |> data/ne_10m_urban_areas_landscan.geojson
: |> curl -L $(GEOBOUNDARIES_URL)/CGAZ/geoBoundariesCGAZ_ADM2.gpkg -o %o |> data/geoBoundariesCGAZ_ADM2.gpkg
: |> curl -L $(GEOBOUNDARIES_URL)/CGAZ/geoBoundariesCGAZ_ADM0.gpkg -o %o |> data/geoBoundariesCGAZ_ADM0.gpkg
# Convert to "valid" GeoPackages
: foreach data/ne_*.geojson |> !makevalid |> data/%B_makevalid.gpkg
: foreach data/geoBoundariesCGAZ_ADM?.gpkg |> !makevalid |> data/%B_makevalid.gpkg
# Build simplified versions
simplify_minpoints=@(SIMPLIFY_MIN_POINTS)
include Tupfile-simplify.lua
# Build tiny wkb (twkb) compressed versions
include Tupfile-compress.lua
# Build preview images
include Tupfile-preview.lua
# Build docgen tool (generate readme)
docgen=docgen$(EXE)
: |> go build ./cmd/docgen |> $(docgen) ^.*/go-build/.*
: $(docgen) data/*.gpkg data/*.png data/*.geojson README.tmpl.md |> $(docgen) -template README.tmpl.md -download $(DOWNLOAD_URI) |> README.md