浏览代码

Add some stuff for the earth silhouettes

master
Fen Dweller 3 年前
父节点
当前提交
6dc05998e1
共有 2 个文件被更改,包括 85 次插入14 次删除
  1. +57
    -0
      scripts/mapshaper/earth.json
  2. +28
    -14
      scripts/mapshaper/map-coords.py

+ 57
- 0
scripts/mapshaper/earth.json 查看文件

@@ -0,0 +1,57 @@
{
"name": "Famous Places",
"directory": "/media/naturals/Earth/",
"shapefile": "E:/macrovision/mapshaper/land/merged.geojson",
"mode": "points",
"layer": "merged",
"items": [
{
"name": "North America",
"file": "E:/macrovision/mapshaper/land/North America.geojson",
"lat": 35,
"lon": -100
},
{
"name": "South America",
"file": "E:/macrovision/mapshaper/land/South America.geojson",
"lat": -13,
"lon": -60
},
{
"name": "Europe",
"file": "E:/macrovision/mapshaper/land/Europe.geojson",
"lat": 48,
"lon": 6
},
{
"name": "Africa",
"file": "E:/macrovision/mapshaper/land/Africa.geojson",
"lat": 5,
"lon": 15
},
{
"name": "Asia",
"file": "E:/macrovision/mapshaper/land/Asia.geojson",
"lat": 50,
"lon": 90
},
{
"name": "Australia",
"file": "E:/macrovision/mapshaper/land/Australia.geojson",
"lat": -24,
"lon": 132
},
{
"name": "North Pole",
"file": "E:/macrovision/mapshaper/land/North Pole.geojson",
"lat": 90,
"lon": 0
},
{
"name": "South Pole",
"file": "E:/macrovision/mapshaper/land/South Pole.geojson",
"lat": -90,
"lon": 0
}
]
}

+ 28
- 14
scripts/mapshaper/map-coords.py 查看文件

@@ -5,31 +5,45 @@ from tqdm import tqdm

config = json.load(open(sys.argv[1]))

if config["mode"] == "bounding-boxes":
if config["mode"] == "points" or config["mode"] == "bounding-boxes":
results = []

for item in config["items"]:
lon0 = item["corner0"][0]
lat0 = item["corner0"][1]
lon1 = item["corner1"][0]
lat1 = item["corner1"][1]

center_lat = (lat0 + lat1) / 2
center_lon = (lon0 + lon1) / 2
if config["mode"] == "bounding-boxes":
lon0 = item["corner0"][0]
lat0 = item["corner0"][1]
lon1 = item["corner1"][0]
lat1 = item["corner1"][1]

center_lat = (lat0 + lat1) / 2
center_lon = (lon0 + lon1) / 2
elif config["mode"] == "points":
lon0 = -180
lat0 = -90
lon1 = 180
lat1 = 90

center_lat = item["lat"]
center_lon = item["lon"]

path = "../../" + config["directory"] + "/" + item["name"] + ".svg"

CMD = """\
mapshaper -i {7} \
mapshaper -i "{7}" \
-rectangle bbox={0},{1},{2},{3} name=rect \
-clip rect target={8} \
-proj crs="+proj=ortho +lon_0={4} +lat_0={5}" target={8},rect \
-info target={8} \
-o "{6}" target={8}
-clip rect target="{8}" \
-proj crs="+proj=ortho +lon_0={4} +lat_0={5}" target="{8}",rect \
-info target="{8}" \
-o "{6}" target="{8}"
"""

file = config["shapefile"]

if "file" in item:
file = item["file"]
try:
prepared = CMD.format(lon0, lat0, lon1, lat1, center_lon, center_lat, path, config["shapefile"], config["layer"])
prepared = CMD.format(lon0, lat0, lon1, lat1, center_lon, center_lat, path, file, item["name"])
result = subprocess.check_output(
prepared,
shell=True,
@@ -44,7 +58,7 @@ if config["mode"] == "bounding-boxes":

results.append([item["name"], height])
except Exception as e:
print(e)
print(e.output)
print(result.decode("utf-8"))

print(json.dumps(results))


正在加载...
取消
保存