1
0
mirror of https://github.com/tumic0/GPXSee-maps.git synced 2024-11-24 11:45:53 +01:00

Added usage info

+ made the mapgen script work with python2
This commit is contained in:
Martin Tůma 2020-02-24 22:29:44 +01:00
parent 2630395713
commit 6c7423d37d
3 changed files with 38 additions and 20 deletions

View File

@ -9,7 +9,13 @@
<body> <body>
<div class="center"> <div class="center">
<h1>GPXSee Online Maps</h1> <h1>GPXSee Online Maps</h1>
<p>GPXSee online map definition files ready to use. Simply download the XML file
and open it in GPXSee as a map file. To use the map permanently, copy the file
to the &quot;maps&quot; directory as found under Help->Paths.</p>
<p><small>Some maps require API keys or user credentials. Such map definition
files have a &quot;.tpl&quot; extension instead of the usual &quot;.xml&quot;
extension. You must fill in the required info and rename the file before you can
use it in GPXSee.</small></p>
<h2>Worldwide</h2> <h2>Worldwide</h2>
<table> <table>
<tr> <tr>
@ -230,4 +236,3 @@
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,9 +1,11 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os import os
import sys import sys
import re import re
import shutil import shutil
import codecs
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
COUNTRYCODES = { COUNTRYCODES = {
@ -262,7 +264,7 @@ def sectionname(name):
return name return name
def header(name, level): def header(name, level):
return "<h" + str(level) + ">" + name + "</h" + str(level) + ">" return "<h" + str(level) + ">" + name + "</h" + str(level) + ">\n"
def tile(xmlfile, suffix): def tile(xmlfile, suffix):
base = os.path.splitext(os.path.basename(xmlfile))[0] base = os.path.splitext(os.path.basename(xmlfile))[0]
@ -294,22 +296,21 @@ def mapinfo(xmlfile):
return info return info
def processmaps(maps, htmlfile): def processmaps(maps, htmlfile):
print("<table>", file=htmlfile) htmlfile.write("<table>\n<tr>\n")
print("<tr>", file=htmlfile)
i = 0 i = 0
for xmlfile in maps: for xmlfile in maps:
shutil.copyfile(xmlfile, "../maps/" + os.path.basename(xmlfile)) shutil.copyfile(xmlfile, "../maps/" + os.path.basename(xmlfile))
info = mapinfo(xmlfile) info = mapinfo(xmlfile)
if i and i % 4 == 0: if i and i % 4 == 0:
print("</tr><tr>", file=htmlfile) htmlfile.write("</tr><tr>\n")
print("<td>" + "<a href=\"" + info["url"] + "\" download><img src=\"" htmlfile.write("<td>" + "<a href=\"" + info["url"] + "\" download><img src=\""
+ info["tile"] + "\" alt=\"Map Preview\" width=\"256\" height=\"256\"/></a><br/>" + info["tile"]
+ info["name"] + "</td>", file=htmlfile) + "\" alt=\"Map Preview\" width=\"256\" height=\"256\"/></a><br/>"
+ info["name"] + "</td>\n")
i = i + 1 i = i + 1
print("</tr>", file=htmlfile) htmlfile.write("</tr>\n</table>\n")
print("</table>", file=htmlfile)
def processdir(path, level, name, htmlfile): def processdir(path, level, name, htmlfile):
maps = [] maps = []
@ -327,17 +328,17 @@ def processdir(path, level, name, htmlfile):
processmaps(maps, htmlfile) processmaps(maps, htmlfile)
sections.sort() sections.sort()
for section in sections: for section in sections:
print(header(section[0], level + 1), file=htmlfile) htmlfile.write(header(section[0], level + 1))
processdir(section[1], level + 1, section[0], htmlfile) processdir(section[1], level + 1, section[0], htmlfile)
if len(sys.argv) < 2: if len(sys.argv) < 2:
print("Usage: " + os.path.basename(sys.argv[0]) + " DIR", file=sys.stderr) sys.stderr.write("Usage: " + os.path.basename(sys.argv[0]) + " WORLDDIR\n")
sys.exit(-1) sys.exit(-1)
htmlfile = open("../index.html", "w") htmlfile = codecs.open("../index.html", "w", encoding='utf-8')
print("""<!DOCTYPE html> htmlfile.write("""<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>GPXSee Online Maps</title> <title>GPXSee Online Maps</title>
@ -348,15 +349,22 @@ print("""<!DOCTYPE html>
<body> <body>
<div class="center"> <div class="center">
<h1>GPXSee Online Maps</h1> <h1>GPXSee Online Maps</h1>
""", file = htmlfile) <p>GPXSee online map definition files ready to use. Simply download the XML file
and open it in GPXSee as a map file. To use the map permanently, copy the file
to the &quot;maps&quot; directory as found under Help->Paths.</p>
<p><small>Some maps require API keys or user credentials. Such map definition
files have a &quot;.tpl&quot; extension instead of the usual &quot;.xml&quot;
extension. You must fill in the required info and rename the file before you can
use it in GPXSee.</small></p>
""")
print(header("Worldwide", 2), file=htmlfile) htmlfile.write(header("Worldwide", 2))
processdir(sys.argv[1], 1, os.path.basename(sys.argv[1]), htmlfile) processdir(sys.argv[1], 1, os.path.basename(sys.argv[1]), htmlfile)
print(""" htmlfile.write("""
</div> </div>
</body> </body>
</html> </html>
""", file=htmlfile) """)
htmlfile.close() htmlfile.close()

View File

@ -34,3 +34,8 @@ h3 {
background:#000000; background:#000000;
border-radius:5px; border-radius:5px;
} }
.center p {
margin-left:10px;
width:60%;
color:#ffffff;
}