-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (59 loc) · 2.31 KB
/
Makefile
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
BIN := ./node_modules/.bin
space := $(eval) $(eval)
comma := ,
TMPDIR := intermediate
ZIPDIR := $(TMPDIR)/zip
SHPDIR := $(TMPDIR)/shp
SIMPLIFY = node --max_old_space_size=8192 bin/simplify
OGR_OPTIONS := -lco COORDINATE_PRECISION=2 -lco WRITE_NAME=NO -lco RFC7946=YES
clean:
rm -rf dist
rm -rf $(TMPDIR)
all: dist/rivers.json dist/land.json dist/boundaries.json dist/lakes.json dist/graticule.json
#################
# Download data #
#################
NE_URL := https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/
$(ZIPDIR)/%.zip:
mkdir -p $(dir $@)
curl -L -o $@ --raw '$(NE_URL)$*.zip'
########################
# Define Zip archives #
########################
$(SHPDIR)/ne_50m_rivers_lake_centerlines_scale_rank.shp: $(ZIPDIR)/50m/physical/ne_50m_rivers_lake_centerlines_scale_rank.zip
$(SHPDIR)/ne_50m_land.shp: $(ZIPDIR)/50m/physical/ne_50m_land.zip
$(SHPDIR)/ne_110m_admin_0_boundary_lines_land.shp: $(ZIPDIR)/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip
$(SHPDIR)/ne_50m_populated_places.shp: $(ZIPDIR)/50m/cultural/ne_50m_populated_places.zip
$(SHPDIR)/ne_50m_lakes.shp: $(ZIPDIR)/50m/physical/ne_50m_lakes.zip
#########################
# Extract Zip archives #
#########################
$(SHPDIR)/ne_%.shp:
mkdir -p $(dir $@)
unzip -o $< -d $(dir $@)
touch $@
################################
# Convert shp files to GeoJSON #
################################
dist/lakes.json: $(SHPDIR)/ne_50m_lakes.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'GeoJSON' $(OGR_OPTIONS) $@ $< -select scalerank,name
dist/places.json: $(SHPDIR)/ne_50m_populated_places.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'GeoJSON' $(OGR_OPTIONS) $@ $< -select SCALERANK,NAME
dist/rivers.json: $(SHPDIR)/ne_50m_rivers_lake_centerlines_scale_rank.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'GeoJSON' $(OGR_OPTIONS) $@ $< -select min_zoom,strokeweig
dist/land.json: $(SHPDIR)/ne_50m_land.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'GeoJSON' $(OGR_OPTIONS) $@ $< -dialect sqlite -sql "SELECT ST_Union(geometry) FROM $(basename $(notdir $<))"
dist/boundaries.json: $(SHPDIR)/ne_110m_admin_0_boundary_lines_land.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'GeoJSON' $(OGR_OPTIONS) $@ $< -dialect sqlite -sql "SELECT ST_Union(geometry) FROM $(basename $(notdir $<))"
dist/graticule.json:
scripts/graticule.js > $@