Commit 671cce3a authored by Benoit ZERR's avatar Benoit ZERR
Browse files

debug pyproj

parent f976dc71
<?xml version="1.0" encoding="UTF-8"?>
<gpx xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" version="1.0" creator="gpx.py -- https://github.com/tkrajina/gpxpy">
<gpx xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" creator="gpx.py -- https://github.com/tkrajina/gpxpy">
<trk>
<trkseg>
<trkpt lat="48.4188" lon="-4.4725"></trkpt>
......
......@@ -4,46 +4,44 @@
# sudo apt install python3-gpxpy
import gpxpy
import gpxpy.gpx
from pyproj import Proj, transform
import numpy as np
projMeter = Proj("+init=EPSG:2263",preserve_units=True)
#projMeter = Proj("+init=EPSG:2154",preserve_units=False) # Lambert-93 - France
#projMeter = Proj("+init=EPSG:5627",preserve_units=False) # ED 50
projMeter = Proj("+init=EPSG:32620",preserve_units=False) # UTM Zone 30
projDegre = Proj("+init=EPSG:4326") # WGS84 in degrees and not EPSG:3857 in meters)
gpx = gpxpy.gpx.GPX()
# Create first track in our GPX:
gpx_track = gpxpy.gpx.GPXTrack()
gpx.tracks.append(gpx_track)
# Create first segment in our GPX track:
gpx_segment = gpxpy.gpx.GPXTrackSegment()
gpx_track.segments.append(gpx_segment)
# reference point "the flag"
reference_lat = 48.4188
reference_lon = -4.4725
gpx_segment.points.append(gpxpy.gpx.GPXTrackPoint(reference_lat, reference_lon))
reference_x,reference_y = transform(projDegre,projMeter,reference_lon,reference_lat)
print (reference_x,reference_y,reference_lat,reference_lon)
x = reference_x
y = reference_y
# reference point center of the rugby field
reference_lat = 48.4185
reference_lon = -4.4739
gpx_segment.points.append(gpxpy.gpx.GPXTrackPoint(reference_lat, reference_lon))
reference_x,reference_y = transform(projDegre,projMeter,reference_lat,reference_lon)
fp = open("reference.gpx","w")
fp.write(gpx.to_xml())
fp.write("\n")
fp.close()
reference_x,reference_y = transform(projDegre,projMeter,reference_lon,reference_lat)
print (reference_x,reference_y,reference_lat,reference_lon)
dx = x - reference_x
dy = y - reference_y
distance = np.sqrt(dx*dx+dy*dy)
print (dx,dy,distance)
exit()
gpx_file = open('tst_ensta_stadium_20210929.gpx', 'r')
init = True
gpx = gpxpy.parse(gpx_file)
for track in gpx.tracks:
for segment in track.segments:
for point in segment.points:
#print('Point at ({0},{1}) -> {2}'.format(point.latitude, point.longitude, point.elevation))
x,y = transform(projDegre,projMeter,point.latitude, point.longitude)
x,y = transform(projDegre,projMeter,point.longitude, point.latitude)
lat,lon = transform(projMeter,projDegre,x,y)
#print (x,y,lat,lon)
print (x,y,lat,lon,point.latitude,point.longitude)
dx = x - reference_x
dy = y - reference_y
distance = np.sqrt(dx*dx+dy*dy)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment