This commit is contained in:
2020-10-13 13:22:15 +02:00
commit 86f5f9a63f
17 changed files with 212232 additions and 0 deletions

3
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@@ -0,0 +1,54 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="41">
<item index="0" class="java.lang.String" itemvalue="cffi" />
<item index="1" class="java.lang.String" itemvalue="numpy" />
<item index="2" class="java.lang.String" itemvalue="requests" />
<item index="3" class="java.lang.String" itemvalue="markupsafe" />
<item index="4" class="java.lang.String" itemvalue="pyrsistent" />
<item index="5" class="java.lang.String" itemvalue="certifi" />
<item index="6" class="java.lang.String" itemvalue="lxml" />
<item index="7" class="java.lang.String" itemvalue="urllib3" />
<item index="8" class="java.lang.String" itemvalue="itsdangerous" />
<item index="9" class="java.lang.String" itemvalue="jsonschema" />
<item index="10" class="java.lang.String" itemvalue="pynacl" />
<item index="11" class="java.lang.String" itemvalue="flask-restx" />
<item index="12" class="java.lang.String" itemvalue="werkzeug" />
<item index="13" class="java.lang.String" itemvalue="six" />
<item index="14" class="java.lang.String" itemvalue="aniso8601" />
<item index="15" class="java.lang.String" itemvalue="flask-jwt-extended" />
<item index="16" class="java.lang.String" itemvalue="cryptography" />
<item index="17" class="java.lang.String" itemvalue="click" />
<item index="18" class="java.lang.String" itemvalue="attrs" />
<item index="19" class="java.lang.String" itemvalue="bcrypt" />
<item index="20" class="java.lang.String" itemvalue="jinja2" />
<item index="21" class="java.lang.String" itemvalue="pandas" />
<item index="22" class="java.lang.String" itemvalue="paramiko" />
<item index="23" class="java.lang.String" itemvalue="user-agents" />
<item index="24" class="java.lang.String" itemvalue="flask" />
<item index="25" class="java.lang.String" itemvalue="pyjwt" />
<item index="26" class="java.lang.String" itemvalue="idna" />
<item index="27" class="java.lang.String" itemvalue="blinker" />
<item index="28" class="java.lang.String" itemvalue="flask-cors" />
<item index="29" class="java.lang.String" itemvalue="flask-httpauth" />
<item index="30" class="java.lang.String" itemvalue="flask-sitemap" />
<item index="31" class="java.lang.String" itemvalue="mariadb" />
<item index="32" class="java.lang.String" itemvalue="tqdm" />
<item index="33" class="java.lang.String" itemvalue="protobuf" />
<item index="34" class="java.lang.String" itemvalue="tabulate" />
<item index="35" class="java.lang.String" itemvalue="pytimeparse" />
<item index="36" class="java.lang.String" itemvalue="sqlite3-to-mysql" />
<item index="37" class="java.lang.String" itemvalue="packaging" />
<item index="38" class="java.lang.String" itemvalue="mysql-connector-python" />
<item index="39" class="java.lang.String" itemvalue="sqlalchemy" />
<item index="40" class="java.lang.String" itemvalue="simplejson" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

View File

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

8
.idea/jens_gps.iml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

4
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Pipenv (jens_gps)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/jens_gps.iml" filepath="$PROJECT_DIR$/.idea/jens_gps.iml" />
</modules>
</component>
</project>

91986
152.GPX Normal file

File diff suppressed because it is too large Load Diff

119816
161.GPX Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

91
Europa.umap Normal file
View File

@@ -0,0 +1,91 @@
{
"type": "umap",
"uri": "https://umap.openstreetmap.fr/de/map/unbenannte-karte_509842",
"properties": {
"easing": true,
"embedControl": true,
"fullscreenControl": true,
"searchControl": true,
"datalayersControl": true,
"zoomControl": true,
"slideshow": {},
"captionBar": false,
"limitBounds": {},
"tilelayer": {},
"licence": "",
"description": "",
"name": "Europa",
"displayPopupFooter": false,
"miniMap": false,
"moreControl": true,
"scaleControl": true,
"scrollWheelZoom": true,
"zoom": 6
},
"geometry": {
"type": "Point",
"coordinates": [
2,
51
]
},
"layers": [
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "#152 Spanien, Andalusien, Tarifa - Kleine Spaziergang durch die Stadt (mit Stephi)",
"id": "152"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
Längengrad 1,
Breitengrad 1
],
[
Längengrad 2,
Breitengrad 2
],
[
usw.
]
]
}
},
{
"type": "Feature",
"properties": {
"name": "#161 Spanien, Andalusien, Trevélez - Das Mekka des Schinkens (mit Stephi)",
"id": "161"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
Längengrad 1,
Breitengrad 1
],
[
Längengrad 2,
Breitengrad 2
],
[
usw.
]
]
}
}
],
"_umap_options": {
"displayOnLoad": true,
"browsable": true,
"name": "Touren",
"id": 1433331
}
}
]
}

13
Pipfile Normal file
View File

@@ -0,0 +1,13 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
gpxpy = "*"
pykml = "*"
[requires]
python_version = "3.8"

72
Pipfile.lock generated Normal file
View File

@@ -0,0 +1,72 @@
{
"_meta": {
"hash": {
"sha256": "e7873caaf0610728fd1dc747926f29729da4eedc84d5bd30b9b3826e794c7955"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"gpxpy": {
"hashes": [
"sha256:0832041899cdfdc5a607291bbef3d73042e16ffcecc3f2cb9631b699db0bb53f"
],
"index": "pypi",
"version": "==1.4.2"
},
"lxml": {
"hashes": [
"sha256:05a444b207901a68a6526948c7cc8f9fe6d6f24c70781488e32fd74ff5996e3f",
"sha256:08fc93257dcfe9542c0a6883a25ba4971d78297f63d7a5a26ffa34861ca78730",
"sha256:107781b213cf7201ec3806555657ccda67b1fccc4261fb889ef7fc56976db81f",
"sha256:121b665b04083a1e85ff1f5243d4a93aa1aaba281bc12ea334d5a187278ceaf1",
"sha256:1fa21263c3aba2b76fd7c45713d4428dbcc7644d73dcf0650e9d344e433741b3",
"sha256:2b30aa2bcff8e958cd85d907d5109820b01ac511eae5b460803430a7404e34d7",
"sha256:4b4a111bcf4b9c948e020fd207f915c24a6de3f1adc7682a2d92660eb4e84f1a",
"sha256:5591c4164755778e29e69b86e425880f852464a21c7bb53c7ea453bbe2633bbe",
"sha256:59daa84aef650b11bccd18f99f64bfe44b9f14a08a28259959d33676554065a1",
"sha256:5a9c8d11aa2c8f8b6043d845927a51eb9102eb558e3f936df494e96393f5fd3e",
"sha256:5dd20538a60c4cc9a077d3b715bb42307239fcd25ef1ca7286775f95e9e9a46d",
"sha256:74f48ec98430e06c1fa8949b49ebdd8d27ceb9df8d3d1c92e1fdc2773f003f20",
"sha256:786aad2aa20de3dbff21aab86b2fb6a7be68064cbbc0219bde414d3a30aa47ae",
"sha256:7ad7906e098ccd30d8f7068030a0b16668ab8aa5cda6fcd5146d8d20cbaa71b5",
"sha256:80a38b188d20c0524fe8959c8ce770a8fdf0e617c6912d23fc97c68301bb9aba",
"sha256:8f0ec6b9b3832e0bd1d57af41f9238ea7709bbd7271f639024f2fc9d3bb01293",
"sha256:92282c83547a9add85ad658143c76a64a8d339028926d7dc1998ca029c88ea6a",
"sha256:94150231f1e90c9595ccc80d7d2006c61f90a5995db82bccbca7944fd457f0f6",
"sha256:9dc9006dcc47e00a8a6a029eb035c8f696ad38e40a27d073a003d7d1443f5d88",
"sha256:a76979f728dd845655026ab991df25d26379a1a8fc1e9e68e25c7eda43004bed",
"sha256:aa8eba3db3d8761db161003e2d0586608092e217151d7458206e243be5a43843",
"sha256:bea760a63ce9bba566c23f726d72b3c0250e2fa2569909e2d83cda1534c79443",
"sha256:c3f511a3c58676147c277eff0224c061dd5a6a8e1373572ac817ac6324f1b1e0",
"sha256:c9d317efde4bafbc1561509bfa8a23c5cab66c44d49ab5b63ff690f5159b2304",
"sha256:cc411ad324a4486b142c41d9b2b6a722c534096963688d879ea6fa8a35028258",
"sha256:cdc13a1682b2a6241080745b1953719e7fe0850b40a5c71ca574f090a1391df6",
"sha256:cfd7c5dd3c35c19cec59c63df9571c67c6d6e5c92e0fe63517920e97f61106d1",
"sha256:e1cacf4796b20865789083252186ce9dc6cc59eca0c2e79cca332bdff24ac481",
"sha256:e70d4e467e243455492f5de463b72151cc400710ac03a0678206a5f27e79ddef",
"sha256:ecc930ae559ea8a43377e8b60ca6f8d61ac532fc57efb915d899de4a67928efd",
"sha256:f161af26f596131b63b236372e4ce40f3167c1b5b5d459b29d2514bd8c9dc9ee"
],
"version": "==4.5.2"
},
"pykml": {
"hashes": [
"sha256:44a1892e7c2a649c8ae9f8e2899ff76cae79ec6749ffb64d11140b4e87d0f957",
"sha256:bd4e259527a88c3b3d0d264c133b8b05bfc457efca37467f7f891b6be937d60e"
],
"index": "pypi",
"version": "==0.2.0"
}
},
"develop": {}
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>#152 Spanien, Andalusien, Tarifa - Kleine Spaziergang durch die Stadt (mit Stephi)</name>
<ExtendedData>
<Data name="name"><value>#152 Spanien, Andalusien, Tarifa - Kleine Spaziergang durch die Stadt (mit Stephi)</value></Data>
<Data name="id"><value>152</value></Data>
</ExtendedData>
<LineString><coordinates>Längengrad1,Breitengrad1 Längengrad2,Breitengrad2 usw.</coordinates></LineString>
</Placemark>
<Placemark>
<name>#161 Spanien, Andalusien, Trevélez - Das Mekka des Schinkens (mit Stephi)</name>
<ExtendedData>
<Data name="name"><value>#161 Spanien, Andalusien, Trevélez - Das Mekka des Schinkens (mit Stephi)</value></Data>
<Data name="id"><value>161</value></Data>
</ExtendedData>
<LineString><coordinates>Längengrad1,Breitengrad1 Längengrad2,Breitengrad2 usw.</coordinates></LineString>
</Placemark>
</Document>
</kml>

View File

@@ -0,0 +1,104 @@
from pprint import pprint
import gpxpy
import gpxpy.gpx
from lxml import etree
from lxml.etree import _ElementTree
from pykml.factory import KML_ElementMaker as KML
from pykml import parser
import os
import logging
def export_coordinates_gpx_file_as_string(file, prepend_file_name=False):
gpx_file = open(file, "r")
logging.info(f"opening {gpx_file}")
gpx = gpxpy.parse(gpx_file)
str = "<LineString><coordinates>"
if prepend_file_name:
if "_" in file:
str = file.split(".")[0].split("_")[1] + "\t" + "<LineString><coordinates>"
else:
str = file.split(".")[0] + "\t" + "<LineString><coordinates>"
for track in gpx.tracks:
for segment in track.segments:
for point in segment.points:
str = str + "{0},{1} ".format(round(point.longitude, 6), round(point.latitude, 6))
return str + "</coordinates></LineString>"
def export_coordinates_gpx_file(file):
gpx_file = open(file, "r")
logging.info(f"opening {gpx_file}")
gpx = gpxpy.parse(gpx_file)
coords = list()
for track in gpx.tracks:
for segment in track.segments:
for point in segment.points:
coords.append("{0},{1} ".format(round(point.longitude, 6), round(point.latitude, 6)))
return coords
def insert_coordinates_into_kml_file(kml_file, search_string, coordinate_string, backup_orig_file=True):
with open(kml_file) as f:
text = f.read()
if backup_orig_file:
if not os.path.exists("backup_" + kml_file):
with open("backup_" + kml_file, "w") as f:
f.write(text)
found_idx = None
splitted_text = text.splitlines()
for i, l in enumerate(splitted_text):
if "name=\"id\"" in l and str(search_string) in l:
found_idx = i
break
if found_idx is not None:
if "<LineString>" in splitted_text[found_idx + 2]:
splitted_text[found_idx + 2] = coordinate_string
text = "\n".join(splitted_text)
with open(kml_file, 'w') as f:
f.write(text)
def create_placemark_from_gpx_file(gpx_file):
coords = " ".join(export_coordinates_gpx_file(gpx_file))
return KML.Placemark(
KML.name(gpx_file.split('.', 1)[0]),
KML.LineString(
KML.coordinates(coords)
),
),
def create_kml_from_gpx_files(kml_file):
pms = list()
for filename in os.listdir(os.getcwd()):
if filename.lower().endswith(".xml") or filename.lower().endswith(".gpx"):
pms.append(create_placemark_from_gpx_file(filename))
doc = KML.kml(KML.name("A third placemark!"),
set(pms))
doc = KML.kml(KML.name("A third placemark!"))
pprint(etree.tostring(doc, pretty_print=True, encoding='utf-8', method='xml').decode('utf-8'))
with open(kml_file, "w") as f:
f.write(etree.tostring(doc, pretty_print=True).decode('utf-8'))
for filename in os.listdir(os.getcwd()):
if filename.lower().endswith(".xml") or filename.lower().endswith(".gpx"):
coords_string = export_coordinates_gpx_file_as_string(filename)
insert_coordinates_into_kml_file("europa_testkarte.kml", filename.split('.', 1)[0], coords_string)
exit()
out = ""
for filename in os.listdir(os.getcwd()):
if filename.lower().endswith(".xml") or filename.lower().endswith(".gpx"):
out = out + export_coordinates_gpx_file(filename) + "\n"
print(out)
exit()
with open("Output.txt", "w") as text_file:
text_file.write(out)

24
europa_testkarte.kml Normal file

File diff suppressed because one or more lines are too long

16
main.py Normal file
View File

@@ -0,0 +1,16 @@
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
# See PyCharm help at https://www.jetbrains.com/help/pycharm/

3
out.kml Normal file
View File

@@ -0,0 +1,3 @@
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gx="http://www.google.com/kml/ext/2.2">
<name>A third placemark!</name>
</kml>