Skip to content

Commit b725e84

Browse files
committed
Refactoring to work off natural earth data. Not storing the data as part of the repo rather supplying a script to fetch just the layers we need - as part of installation...
1 parent 85ac4ef commit b725e84

23 files changed

+91
-502
lines changed

data/.gitkeep

Whitespace-only changes.

data/minnesota_counties.dbf

-13.7 KB
Binary file not shown.

data/minnesota_counties.prj

-1
This file was deleted.

data/minnesota_counties.shp

-1.16 MB
Binary file not shown.

data/minnesota_counties.shx

-1.01 KB
Binary file not shown.

data/ne_10m_populated_places.README.html

-448
This file was deleted.

data/ne_10m_populated_places.VERSION.txt

-1
This file was deleted.

data/ne_10m_populated_places.cpg

-1
This file was deleted.

data/ne_10m_populated_places.dbf

-68.3 MB
Binary file not shown.

data/ne_10m_populated_places.prj

-1
This file was deleted.

data/ne_10m_populated_places.shp

-201 KB
Binary file not shown.

data/ne_10m_populated_places.shx

-57.5 KB
Binary file not shown.

data/raster/HYP_50M_SR_W_YCBCR.tif

-4.7 MB
Binary file not shown.

fetch_natural_earth_data.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
# clean out anything previously downloaded
4+
rm -rf data/natural_earth_vector data/natural_earth_raster
5+
mkdir data/natural_earth_vector data/natural_earth_raster
6+
7+
#
8+
# Natural Earth 50m Cultural Data
9+
#
10+
layers=(ne_50m_admin_0_countries ne_50m_populated_places)
11+
for l in ${layers[@]}; do
12+
wget -N https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/${l}.zip
13+
unzip ${l}.zip -d data/natural_earth_vector/50m_cultural
14+
rm ${l}.zip
15+
done
16+
17+
#
18+
# Natural Earth 50m Physical Data
19+
#
20+
layers=()
21+
for l in ${layers[@]}; do
22+
wget -N https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/physical/${l}.zip
23+
unzip ${l}.zip -d data/natural_earth_vector/50m_physical
24+
rm ${l}
25+
done
26+
27+
#
28+
# Natural Earth 50m Raster Data
29+
#
30+
layers=(HYP_50M_SR)
31+
for l in ${layers[@]}; do
32+
wget -N https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/raster/${l}.zip
33+
unzip ${l}.zip -d data/natural_earth_raster/50m_raster
34+
rm ${l}.zip
35+
done

htdocs/js/utility.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function decode(string) {
2+
return unescape(string.replace(/\+/g, " "));
3+
}
4+
function getargs() {
5+
var args = new Object();
6+
var query = location.search.substring(1);
7+
var pairs = query.split("&");
8+
for(var i = 0; i < pairs.length; i++) {
9+
var pos = pairs[i].indexOf('=');
10+
if (pos == -1) continue;
11+
var argname = pairs[i].substring(0,pos);
12+
var value = pairs[i].substring(pos+1);
13+
args[argname] = decode(value);
14+
}
15+
return args;
16+
}

htdocs/snippet.html

+3-18
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<style>
1010
.hilite { background-color: yellow; }
1111
</style>
12+
<script src="js/utility.js"></script>
1213
<script src="snippets.js"></script>
1314
</head>
1415
<body>
@@ -26,8 +27,8 @@
2627
<h2><%= snippet.title %></h2>
2728
<p><%= snippet.description %></p>
2829
<div class="row">
29-
<div class="col-sm"><h3>Input</h3><div id="input" class="card card-body bg-light"></div></div>
30-
<div class="col-sm"><h3>Output</h3><div id="output"></div></div>
30+
<div class="col-sm-6"><h3>Input</h3><div id="input" class="card card-body bg-light"></div></div>
31+
<div class="col-sm-6"><h3>Output</h3><div id="output"></div></div>
3132
</div>
3233
<div>
3334
<strong>Author:</strong> <%= snippet.author %><br/>
@@ -77,22 +78,6 @@ <h4>Mapfile Code</h4>
7778

7879
return lines.join("\r");
7980
}
80-
function decode(string) {
81-
return unescape(string.replace(/\+/g, " "));
82-
}
83-
function getargs() {
84-
var args = new Object();
85-
var query = location.search.substring(1);
86-
var pairs = query.split("&");
87-
for(var i = 0; i < pairs.length; i++) {
88-
var pos = pairs[i].indexOf('=');
89-
if (pos == -1) continue;
90-
var argname = pairs[i].substring(0,pos);
91-
var value = pairs[i].substring(pos+1);
92-
args[argname] = decode(value);
93-
}
94-
return args;
95-
}
9681

9782
$(document).ready(function() {
9883
snippet_template = _.template($("#snippet_template").html());

htdocs/snippets.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function urlParamsToJSON() { // eslint-disable-line no-unused-vars
2323
}
2424

2525
var urlParams = urlParamsToJSON();
26-
var mapserv = urlParams.mapserv || '/cgi-bin/mapserv74';
26+
var mapserv = urlParams.mapserv || '/cgi-bin/mapserv';
2727
var mapfile = urlParams.mapfile || 'MAPSERVER_SNIPPETS';
2828
var baseurl = mapserv + '?MAP=' + mapfile;
2929
var center = urlParams.center ? JSON.parse(urlParams.center) : [30,40];

snippets.map

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
MAP
22
NAME 'snippets'
33

4-
EXTENT 125000 4785000 789000 5489000
4+
EXTENT -20026376.39 -20048966.10 20026376.39 20048966.10
55
UNITS METERS
6+
67
SIZE 500 500
78

89
SHAPEPATH ./data
9-
IMAGETYPE png # req'd for native mapserv protocol
10+
IMAGETYPE PNG
11+
12+
PROJECTION
13+
"init=epsg:3857" # web Mercator
14+
END
1015

1116
WEB
1217
METADATA
13-
"wms_title" "OWS Demo Server"
18+
"wms_title" "MapServer Snippets"
1419
"ows_enable_request" "*"
1520
"wms_onlineresource" "http://my.host.com/cgi-bin/mapserv?map=ows.map&"
1621
"wfs_getfeature_formatlist" "gml,geojson"
1722
"ows_srs" "EPSG:4326 EPSG:3857"
1823
END
19-
END # web
24+
END
2025

2126
OUTPUTFORMAT
2227
NAME "geojson"
@@ -27,11 +32,6 @@ MAP
2732
FORMATOPTION "USE_FEATUREID=true"
2833
END
2934

30-
PROJECTION # default projection
31-
"init=epsg:3857" # web mercator
32-
# "init=epsg:4326" # wgs84 lat/long
33-
END
34-
3535
SCALEBAR
3636
STYLE 0
3737
INTERVALS 2

snippets/color01.snippet

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
LAYER
22
NAME 'color01'
3-
DATA 'data/minnesota_counties'
3+
DATA 'data/natural_earth_vector/50m_cultural/ne_50m_admin_0_countries'
4+
PROJECTION "init=EPSG:4326" END
45
TYPE POLYGON
56
STATUS OFF
6-
CLASSITEM 'cty_abbr'
7-
CLASS
8-
EXPRESSION 'ANOK'
7+
CLASSITEM 'ISO_A3'
8+
CLASS
9+
EXPRESSION 'CAN'
910
STYLE
1011
COLOR 0 0 255 # hilite
11-
OUTLINECOLOR 181 181 181
12+
OUTLINECOLOR 51 51 51
1213
END
1314
END
1415
CLASS
15-
EXPRESSION 'STLO'
16+
EXPRESSION 'CHN'
1617
STYLE
17-
COLOR "#0000FF" # hilite
18-
OUTLINECOLOR 181 181 181
18+
COLOR "#00FF00" # hilite
19+
OUTLINECOLOR 51 51 51
1920
END
2021
END
2122
CLASS
22-
EXPRESSION 'ITAS'
23+
EXPRESSION 'USA'
2324
STYLE
24-
COLOR "#0000FF66" # hilite
25-
OUTLINECOLOR 181 181 181
25+
COLOR "#FF000066" # hilite
26+
OUTLINECOLOR 51 51 51
2627
END
2728
END
2829
CLASS
2930
STYLE
30-
OUTLINECOLOR 181 181 181
31+
OUTLINECOLOR 51 51 51
3132
END
3233
END
3334
END

snippets/regex01.snippet

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
LAYER
22
NAME 'regex01'
3-
DATA 'data/minnesota_counties'
3+
DATA 'data/natural_earth_vector/50m_cultural/ne_50m_admin_0_countries'
4+
PROJECTION "init=EPSG:4326" END
45
TYPE POLYGON
56
STATUS OFF
6-
CLASSITEM 'cty_name'
7+
CLASSITEM 'NAME'
78
CLASS
89
EXPRESSION /C/ # hilite
910
STYLE
1011
COLOR 255 0 0
11-
OUTLINECOLOR 181 181 181
12+
OUTLINECOLOR 51 51 51
1213
END
1314
END
1415
CLASS
1516
STYLE
16-
OUTLINECOLOR 181 181 181
17+
OUTLINECOLOR 51 51 51
1718
END
1819
END
1920
END

snippets/regex02.snippet

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
LAYER
22
NAME 'regex02'
3-
DATA 'data/minnesota_counties'
3+
DATA 'data/natural_earth_vector/50m_cultural/ne_50m_admin_0_countries'
4+
PROJECTION "init=EPSG:4326" END
45
TYPE POLYGON
56
STATUS OFF
6-
CLASSITEM 'cty_name'
7+
CLASSITEM 'NAME'
78
CLASS
89
EXPRESSION /C/i # hilite
910
STYLE

snippets/regex03.snippet

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
LAYER
22
NAME 'regex03'
3-
DATA 'data/minnesota_counties'
3+
DATA 'data/natural_earth_vector/50m_cultural/ne_50m_admin_0_countries'
4+
PROJECTION "init=EPSG:4326" END
45
TYPE POLYGON
56
STATUS OFF
67
CLASS
7-
EXPRESSION ('[cty_name]' ~ 'C') # hilite
8+
EXPRESSION ('[name]' ~ 'C') # hilite
89
STYLE
910
COLOR 255 0 0
1011
OUTLINECOLOR 181 181 181

snippets/regex04.snippet

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
LAYER
22
NAME 'regex04'
3-
DATA 'data/minnesota_counties'
3+
DATA 'data/natural_earth_vector/50m_cultural/ne_50m_admin_0_countries'
4+
PROJECTION "init=EPSG:4326" END
45
TYPE POLYGON
56
STATUS OFF
67
CLASS
7-
EXPRESSION ('[cty_name]' ~* 'C') # hilite
8+
EXPRESSION ('[name]' ~* 'C') # hilite
89
STYLE
910
COLOR 255 0 0
1011
OUTLINECOLOR 181 181 181

0 commit comments

Comments
 (0)