-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new rudymap_download script
- Loading branch information
Showing
13 changed files
with
8,400 additions
and
22 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 花蓮地震圖層 hl20240403 製作 Note 20240813 | ||
|
||
1. 原始檔案 gpx 匯入 Qgis 3.16, 只取tracks | ||
|
||
1. 將圖層匯出成 geojson, (Optional: Vector->Geometry Tools->Line to polygon ) | ||
|
||
1. 使用 exportpbf 的 geojsontoosm 轉換成 osm | ||
``` | ||
geojsontoosm HL3.geojson > HL.osm | ||
``` | ||
1. osm 裡面的 description 太長, strip 掉(CludeAI 幫忙寫的) | ||
``` | ||
python rmdesc.py 產生 HL_ref.osm | ||
``` | ||
1. 將 osm 轉成 pbf | ||
``` | ||
osmium sort --overwrite HL_ref.osm -o HL.pbf | ||
``` | ||
1. 將 pbf 轉成 | ||
``` | ||
pbf2map.php | ||
``` | ||
1. 使用 mapsforgesrv 將 tile serve 出去 | ||
``` | ||
#!/bin/bash | ||
export JAVA_FONTS=/usr/share/fonts/truetype/msttcorefonts/ | ||
mapsforgesrv_bin="java -Xmx512m -jar /home/happyman/mapsforge/mapsforgesrv-fatjar.jar" | ||
cd /home/happyman/mapsforge | ||
exec setuidgid happyman $mapsforgesrv_bin -m HL.map -t HL.xml -o elmt-track,elmt-waymarks,elmt-waypoint -p 8994 | ||
``` | ||
其中 HL.xml 是直接複製 MOI_OSM_twmap.xml 只改 gpx trk 的 <rule e="way" k="color" v="~"> 的顏色 | ||
1. tilestache 做 proxy, 記得 transparent=true, nginx 的 reverse proxy 設定 | ||
1. 感謝東華大學張光承提供 原始檔案 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
$dd="./eq"; | ||
exec("mkdir -p $dd"); | ||
|
||
$finalmap="$dd/HL.map"; | ||
$finalpbf="./HL.pbf"; | ||
$cmt="Rock Slides after 202404 earthquake"; | ||
$log="$dd/HL.log"; | ||
|
||
$mapping_xml = "/home/happyman/projects/taiwan-topo/osm_scripts/gpx-mapping.xml"; | ||
$osmosis_bin = "/home/happyman/projects/taiwan-topo/tools/osmosis-0.48.3/bin/osmosis"; | ||
echo "finally...\n"; | ||
if (!file_exists($finalmap)){ | ||
$cmd = sprintf("export JAVACMD_OPTIONS=\"-Xmx30G\"; | ||
unbuffer $osmosis_bin \ | ||
--read-pbf \"%s\" \ | ||
--buffer --mapfile-writer \ | ||
type=ram \ | ||
threads=8 \ | ||
bbox=21.55682,118.12141,26.44212,122.31377 \ | ||
preferred-languages=\"zh,en\" \ | ||
tag-conf-file=\"%s\" \ | ||
polygon-clipping=true way-clipping=true label-position=false \ | ||
zoom-interval-conf=6,0,6,10,7,11,14,12,21 \ | ||
map-start-zoom=10 \ | ||
comment=\"%s / (c) Map: Happyman\" \ | ||
file=\"%s\" > %s 2>&1 &", | ||
$finalpbf, $mapping_xml, $cmt, $finalmap , $log); | ||
|
||
// not yet | ||
echo $cmd; | ||
$pid = exec($cmd); | ||
echo "process in background...\n"; | ||
while(1) { | ||
//system("tail -1 $log"); | ||
exec(sprintf("fgrep \"finished...\" %s",$log),$out,$ret); | ||
if ($ret == 0 ) { | ||
exec("ps ax |grep osmosis |grep java |awk '{print $1}' |xargs kill"); | ||
echo "done...\n"; | ||
break; | ||
} | ||
sleep(10); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import xml.etree.ElementTree as ET | ||
import os | ||
if not os.path.exists('descriptions'): | ||
os.makedirs('descriptions') | ||
inf='HL.osm' | ||
outf='HL_ref.osm' | ||
# Parse the OSM file | ||
tree = ET.parse(inf) | ||
root = tree.getroot() | ||
# Counter for generating unique file names | ||
counter = 1 | ||
# Find all tag elements with k="description" | ||
for tag in root.findall(".//tag[@k='description']"): | ||
# Get the original description | ||
original_description = tag.get('v') | ||
# Generate a unique filename | ||
filename = f"desc_{counter}.html" | ||
# Save the original description to an HTML file | ||
with open(os.path.join('descriptions', filename), 'w', encoding='utf-8') as f: | ||
f.write(original_description) | ||
# Replace the original description with a reference | ||
tag.set('v', f"See {filename}") | ||
# Increment the counter | ||
counter += 1 | ||
# Write the modified XML back to a file | ||
tree.write(outf, encoding='utf-8', xml_declaration=True) | ||
print(f"Processed {counter-1} description tags. to {outf}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters