From 3293df2b80acfc4ea4a20b8d18b77ae57fd6a99d Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sat, 13 Mar 2021 15:17:38 -0500 Subject: [PATCH] Add some straits (under Naturals) Also adds the scripts used to generate them. --- media/attribution.js | 7 +++ media/naturals/straits/Strait of Dover.svg | 7 +++ .../naturals/straits/Strait of Gibraltar.svg | 6 +++ media/naturals/straits/Strait of Hormuz.svg | 8 +++ .../straits/Strait of Juan de Fuca.svg | 11 +++++ media/naturals/straits/Strait of Messina.svg | 7 +++ media/naturals/straits/Strait of Otranto.svg | 7 +++ presets/naturals.js | 11 +++++ scripts/mapshaper/straits.json | 49 +++++++++++++++++++ scripts/mapshaper/straits.py | 42 ++++++++++++++++ 10 files changed, 155 insertions(+) create mode 100644 media/naturals/straits/Strait of Dover.svg create mode 100644 media/naturals/straits/Strait of Gibraltar.svg create mode 100644 media/naturals/straits/Strait of Hormuz.svg create mode 100644 media/naturals/straits/Strait of Juan de Fuca.svg create mode 100644 media/naturals/straits/Strait of Messina.svg create mode 100644 media/naturals/straits/Strait of Otranto.svg create mode 100644 scripts/mapshaper/straits.json create mode 100644 scripts/mapshaper/straits.py diff --git a/media/attribution.js b/media/attribution.js index fd61f52a..013f3efb 100644 --- a/media/attribution.js +++ b/media/attribution.js @@ -15294,6 +15294,13 @@ const attributionData = { "openstreetmap" ] }, + { + prefix: "./media/naturals/straits", + all: "https://www.naturalearthdata.com/downloads/10m-physical-vectors/", + authors: [ + "naturalearth" + ] + }, { prefix: "./media/food/plants/", files: [ diff --git a/media/naturals/straits/Strait of Dover.svg b/media/naturals/straits/Strait of Dover.svg new file mode 100644 index 00000000..2f3041ac --- /dev/null +++ b/media/naturals/straits/Strait of Dover.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/media/naturals/straits/Strait of Gibraltar.svg b/media/naturals/straits/Strait of Gibraltar.svg new file mode 100644 index 00000000..ae2d7956 --- /dev/null +++ b/media/naturals/straits/Strait of Gibraltar.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/media/naturals/straits/Strait of Hormuz.svg b/media/naturals/straits/Strait of Hormuz.svg new file mode 100644 index 00000000..98ec6d5d --- /dev/null +++ b/media/naturals/straits/Strait of Hormuz.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/media/naturals/straits/Strait of Juan de Fuca.svg b/media/naturals/straits/Strait of Juan de Fuca.svg new file mode 100644 index 00000000..c4d0a55b --- /dev/null +++ b/media/naturals/straits/Strait of Juan de Fuca.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/media/naturals/straits/Strait of Messina.svg b/media/naturals/straits/Strait of Messina.svg new file mode 100644 index 00000000..f6f6cbbc --- /dev/null +++ b/media/naturals/straits/Strait of Messina.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/media/naturals/straits/Strait of Otranto.svg b/media/naturals/straits/Strait of Otranto.svg new file mode 100644 index 00000000..296ab3b2 --- /dev/null +++ b/media/naturals/straits/Strait of Otranto.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/presets/naturals.js b/presets/naturals.js index 0074760e..b393ab8d 100644 --- a/presets/naturals.js +++ b/presets/naturals.js @@ -894,6 +894,8 @@ const globalCityData = [ ["Beijing", 16426832679.115694, 178940.11723688344], ] +const straitData = [["Strait of Dover", 31174983454.928658, 222577.01735751258], ["Strait of Gibraltar", 4012438156.156927, 55658.19643643095], ["Strait of Hormuz", 25574748008.534893, 122431.35146918982], ["Strait of Messina", 97316549.67370307, 11131.941670965367], ["Strait of Otranto", 30353100830.64735, 189202.32829987607], ["Strait of Juan de Fuca", 36469939347.95791, 178049.49203886717]] + function makePlanet(name, diameter, mass, image) { return { name: name, @@ -1108,6 +1110,15 @@ function makeNaturals() { "Global Cities", false )); + + results.push(makeGIS( + straitData.sort((s1, s2) => { + return s1[0].localeCompare(s2[0]) + }), + "Straits", + false + )); + results.sort((b1, b2) => { e1 = b1.constructor(); e2 = b2.constructor(); diff --git a/scripts/mapshaper/straits.json b/scripts/mapshaper/straits.json new file mode 100644 index 00000000..abbac789 --- /dev/null +++ b/scripts/mapshaper/straits.json @@ -0,0 +1,49 @@ +{ + "name": "Straits", + "directory": "/media/naturals/straits/", + "shapefile": "E:/macrovision/mapshaper/straits/ne_10m_land.shp", + "items": [ + { + "name": "Strait of Dover", + "lat0": 50, + "lon0": 0, + "lat1": 52, + "lon1": 2 + }, + { + "name": "Strait of Gibraltar", + "lat0": 35.7, + "lon0": -6.1, + "lat1": 36.2, + "lon1": -5.3 + }, + { + "name": "Strait of Hormuz", + "lat0": 26.1, + "lon0": 55.2, + "lat1": 27.2, + "lon1": 57.3 + }, + { + "name": "Strait of Messina", + "lat0": 38.2, + "lon0": 15.6, + "lat1": 38.3, + "lon1": 15.7 + }, + { + "name": "Strait of Otranto", + "lat0": 39.8, + "lon0": 17.9, + "lat1": 41.5, + "lon1": 19.8 + }, + { + "name": "Strait of Juan de Fuca", + "lat0": 48.1, + "lon0": -125.1, + "lat1": 49.7, + "lon1": -122.3 + } + ] +} \ No newline at end of file diff --git a/scripts/mapshaper/straits.py b/scripts/mapshaper/straits.py new file mode 100644 index 00000000..4837cd0e --- /dev/null +++ b/scripts/mapshaper/straits.py @@ -0,0 +1,42 @@ +import json +import sys +import subprocess + +config = json.load(open(sys.argv[1])) +results = [] + +for item in config["items"]: + lon0 = item["lon0"] + lat0 = item["lat0"] + lon1 = item["lon1"] + lat1 = item["lat1"] + + center_lat = (lat0 + lat1) / 2 + center_lon = (lon0 + lon1) / 2 + + path = "../../" + config["directory"] + "/" + item["name"] + ".svg" + + CMD = """\ + mapshaper -i {7} \ + -rectangle bbox={0},{1},{2},{3} name=rect \ + -clip rect target=ne_10m_land \ + -proj crs="+proj=nsper +h=10000000 +lon_0={4} +lat_0={5}" target=ne_10m_land,rect \ + -each 'console.log(this.bounds.concat([this.area]))' target=rect \ + -o "{6}" target=ne_10m_land + """ + + prepared = CMD.format(lon0, lat0, lon1, lat1, center_lon, center_lat, path, config["shapefile"]) + print(prepared) + result = subprocess.check_output( + prepared, + shell=True + ) + + data = json.loads(result.decode("utf-8")) + + height = data[3] - data[1] + area = data[4] + + results.append([item["name"], area, height]) + +print(json.dumps(results)) \ No newline at end of file