mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-17 20:34:23 +02:00
Compare commits
79 Commits
Author | SHA1 | Date | |
---|---|---|---|
67c8602efd | |||
a324698a67 | |||
23bf3397b8 | |||
db2d0b63e8 | |||
e7cfeb0d1a | |||
366e84c9fc | |||
3424b3e265 | |||
cb80389d74 | |||
40276e8b95 | |||
106904a763 | |||
e21d89e998 | |||
a432ff3461 | |||
201256d882 | |||
b2a34bd10f | |||
63cf4c039a | |||
ca97ca392e | |||
ec5ad67a3e | |||
569ded1e25 | |||
8e713a1f06 | |||
f07173ab22 | |||
cf6d27b1f5 | |||
fc18283172 | |||
1cd726691e | |||
24835db090 | |||
2352827d9b | |||
c5a060ed6b | |||
026cc68bf2 | |||
ec247d5d1d | |||
815cb6cb91 | |||
ca7016176f | |||
2c816a509b | |||
58e752a022 | |||
7d412a274d | |||
6bee2a46f1 | |||
eeab6a399e | |||
9e04bf0fa7 | |||
2842c6c125 | |||
bafd0b6af2 | |||
eb89ef2f2b | |||
f9822b7c78 | |||
e4feeae064 | |||
31ff81576c | |||
0d879e61a9 | |||
ba7074f902 | |||
f371500570 | |||
7324535bfc | |||
59c95e53c4 | |||
a66ca7b3a8 | |||
273a918ed9 | |||
7198d610c5 | |||
a6389f0174 | |||
d9c922aa47 | |||
0156d2fbc0 | |||
650eb1c302 | |||
33919c501c | |||
be9da5aabe | |||
f341219613 | |||
a486f9e78d | |||
b3940283a8 | |||
74aebce357 | |||
0cd6a82a0f | |||
81a5c712c6 | |||
025a403c73 | |||
a762445bce | |||
e1a87c84f3 | |||
5f47383648 | |||
7a702be012 | |||
abfb0c637a | |||
c9cedebeb0 | |||
be1c7fa4c2 | |||
2b421f3b63 | |||
80f13d7057 | |||
ab05014896 | |||
c8433f7b55 | |||
bb52003743 | |||
22ea1b0bca | |||
adb407dcf5 | |||
3b0a4a30bb | |||
792ec17a20 |
@ -1,4 +1,4 @@
|
|||||||
version: 5.10.{build}
|
version: 5.15.{build}
|
||||||
configuration: Release
|
configuration: Release
|
||||||
platform: Any CPU
|
platform: Any CPU
|
||||||
environment:
|
environment:
|
||||||
|
@ -4,7 +4,7 @@ KML, FIT, IGC, NMEA and OziExplorer files.
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
* User-definable online maps (OSM/Google tiles, WMTS, WMS).
|
* User-definable online maps (OSM/Google tiles, WMTS, WMS).
|
||||||
* Offline maps (OziExplorer maps, TrekBuddy maps/atlases, GeoTIFF images).
|
* Offline maps (OziExplorer maps, TrekBuddy maps/atlases, Garmin JNX maps, GeoTIFF images).
|
||||||
* Elevation, speed, heart rate, cadence, power and temperature graphs.
|
* Elevation, speed, heart rate, cadence, power and temperature graphs.
|
||||||
* Support for multiple tracks in one view.
|
* Support for multiple tracks in one view.
|
||||||
* Support for POI files.
|
* Support for POI files.
|
||||||
|
26
gpxsee.pro
26
gpxsee.pro
@ -1,5 +1,5 @@
|
|||||||
TARGET = GPXSee
|
TARGET = GPXSee
|
||||||
VERSION = 5.10
|
VERSION = 5.15
|
||||||
QT += core \
|
QT += core \
|
||||||
gui \
|
gui \
|
||||||
network
|
network
|
||||||
@ -15,6 +15,7 @@ HEADERS += src/config.h \
|
|||||||
src/common/rectc.h \
|
src/common/rectc.h \
|
||||||
src/common/wgs84.h \
|
src/common/wgs84.h \
|
||||||
src/common/str2int.h \
|
src/common/str2int.h \
|
||||||
|
src/common/rtree.h \
|
||||||
src/GUI/app.h \
|
src/GUI/app.h \
|
||||||
src/GUI/icons.h \
|
src/GUI/icons.h \
|
||||||
src/GUI/gui.h \
|
src/GUI/gui.h \
|
||||||
@ -48,6 +49,7 @@ HEADERS += src/config.h \
|
|||||||
src/GUI/format.h \
|
src/GUI/format.h \
|
||||||
src/GUI/cadencegraph.h \
|
src/GUI/cadencegraph.h \
|
||||||
src/GUI/powergraph.h \
|
src/GUI/powergraph.h \
|
||||||
|
src/GUI/gearratiograph.h \
|
||||||
src/GUI/optionsdialog.h \
|
src/GUI/optionsdialog.h \
|
||||||
src/GUI/colorbox.h \
|
src/GUI/colorbox.h \
|
||||||
src/GUI/stylecombobox.h \
|
src/GUI/stylecombobox.h \
|
||||||
@ -60,6 +62,7 @@ HEADERS += src/config.h \
|
|||||||
src/GUI/temperaturegraphitem.h \
|
src/GUI/temperaturegraphitem.h \
|
||||||
src/GUI/cadencegraphitem.h \
|
src/GUI/cadencegraphitem.h \
|
||||||
src/GUI/powergraphitem.h \
|
src/GUI/powergraphitem.h \
|
||||||
|
src/GUI/gearratiographitem.h \
|
||||||
src/GUI/oddspinbox.h \
|
src/GUI/oddspinbox.h \
|
||||||
src/GUI/settings.h \
|
src/GUI/settings.h \
|
||||||
src/GUI/nicenum.h \
|
src/GUI/nicenum.h \
|
||||||
@ -69,7 +72,7 @@ HEADERS += src/config.h \
|
|||||||
src/map/projection.h \
|
src/map/projection.h \
|
||||||
src/map/ellipsoid.h \
|
src/map/ellipsoid.h \
|
||||||
src/map/datum.h \
|
src/map/datum.h \
|
||||||
src/map/mercator.h \
|
src/map/webmercator.h \
|
||||||
src/map/transversemercator.h \
|
src/map/transversemercator.h \
|
||||||
src/map/latlon.h \
|
src/map/latlon.h \
|
||||||
src/map/utm.h \
|
src/map/utm.h \
|
||||||
@ -117,7 +120,6 @@ HEADERS += src/config.h \
|
|||||||
src/data/trackdata.h \
|
src/data/trackdata.h \
|
||||||
src/data/routedata.h \
|
src/data/routedata.h \
|
||||||
src/data/path.h \
|
src/data/path.h \
|
||||||
src/data/rtree.h \
|
|
||||||
src/data/gpxparser.h \
|
src/data/gpxparser.h \
|
||||||
src/data/tcxparser.h \
|
src/data/tcxparser.h \
|
||||||
src/data/csvparser.h \
|
src/data/csvparser.h \
|
||||||
@ -126,7 +128,11 @@ HEADERS += src/config.h \
|
|||||||
src/data/igcparser.h \
|
src/data/igcparser.h \
|
||||||
src/data/nmeaparser.h \
|
src/data/nmeaparser.h \
|
||||||
src/data/oziparsers.h \
|
src/data/oziparsers.h \
|
||||||
src/map/rectd.h
|
src/map/rectd.h \
|
||||||
|
src/map/geocentric.h \
|
||||||
|
src/map/mercator.h \
|
||||||
|
src/map/jnxmap.h \
|
||||||
|
src/map/krovak.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/common/coordinates.cpp \
|
src/common/coordinates.cpp \
|
||||||
src/common/rectc.cpp \
|
src/common/rectc.cpp \
|
||||||
@ -160,6 +166,7 @@ SOURCES += src/main.cpp \
|
|||||||
src/GUI/format.cpp \
|
src/GUI/format.cpp \
|
||||||
src/GUI/cadencegraph.cpp \
|
src/GUI/cadencegraph.cpp \
|
||||||
src/GUI/powergraph.cpp \
|
src/GUI/powergraph.cpp \
|
||||||
|
src/GUI/gearratiograph.cpp \
|
||||||
src/GUI/optionsdialog.cpp \
|
src/GUI/optionsdialog.cpp \
|
||||||
src/GUI/colorbox.cpp \
|
src/GUI/colorbox.cpp \
|
||||||
src/GUI/stylecombobox.cpp \
|
src/GUI/stylecombobox.cpp \
|
||||||
@ -171,6 +178,7 @@ SOURCES += src/main.cpp \
|
|||||||
src/GUI/temperaturegraphitem.cpp \
|
src/GUI/temperaturegraphitem.cpp \
|
||||||
src/GUI/cadencegraphitem.cpp \
|
src/GUI/cadencegraphitem.cpp \
|
||||||
src/GUI/powergraphitem.cpp \
|
src/GUI/powergraphitem.cpp \
|
||||||
|
src/GUI/gearratiographitem.cpp \
|
||||||
src/GUI/nicenum.cpp \
|
src/GUI/nicenum.cpp \
|
||||||
src/GUI/mapview.cpp \
|
src/GUI/mapview.cpp \
|
||||||
src/map/maplist.cpp \
|
src/map/maplist.cpp \
|
||||||
@ -184,7 +192,7 @@ SOURCES += src/main.cpp \
|
|||||||
src/map/matrix.cpp \
|
src/map/matrix.cpp \
|
||||||
src/map/ellipsoid.cpp \
|
src/map/ellipsoid.cpp \
|
||||||
src/map/datum.cpp \
|
src/map/datum.cpp \
|
||||||
src/map/mercator.cpp \
|
src/map/webmercator.cpp \
|
||||||
src/map/transversemercator.cpp \
|
src/map/transversemercator.cpp \
|
||||||
src/map/utm.cpp \
|
src/map/utm.cpp \
|
||||||
src/map/lambertconic.cpp \
|
src/map/lambertconic.cpp \
|
||||||
@ -220,7 +228,12 @@ SOURCES += src/main.cpp \
|
|||||||
src/data/fitparser.cpp \
|
src/data/fitparser.cpp \
|
||||||
src/data/igcparser.cpp \
|
src/data/igcparser.cpp \
|
||||||
src/data/nmeaparser.cpp \
|
src/data/nmeaparser.cpp \
|
||||||
src/data/oziparsers.cpp
|
src/data/oziparsers.cpp \
|
||||||
|
src/map/geocentric.cpp \
|
||||||
|
src/map/mercator.cpp \
|
||||||
|
src/map/jnxmap.cpp \
|
||||||
|
src/map/krovak.cpp \
|
||||||
|
src/map/map.cpp
|
||||||
RESOURCES += gpxsee.qrc
|
RESOURCES += gpxsee.qrc
|
||||||
TRANSLATIONS = lang/gpxsee_cs.ts \
|
TRANSLATIONS = lang/gpxsee_cs.ts \
|
||||||
lang/gpxsee_sv.ts \
|
lang/gpxsee_sv.ts \
|
||||||
@ -267,5 +280,6 @@ win32 {
|
|||||||
icons/plt.ico \
|
icons/plt.ico \
|
||||||
icons/rte.ico \
|
icons/rte.ico \
|
||||||
icons/wpt.ico
|
icons/wpt.ico
|
||||||
|
DEFINES += _USE_MATH_DEFINES
|
||||||
}
|
}
|
||||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@ Modified Airy,7002,6377340.189,299.3249646
|
|||||||
Australian National,7003,6378160.0,298.25
|
Australian National,7003,6378160.0,298.25
|
||||||
Bessel 1841,7004,6377397.155,299.1528128
|
Bessel 1841,7004,6377397.155,299.1528128
|
||||||
Bessel 1841 (Norway),7005,6377492.0176,299.1528
|
Bessel 1841 (Norway),7005,6377492.0176,299.1528
|
||||||
|
Clarke 1858,7007,6378293.645,294.26
|
||||||
Clarke 1866,7008,6378206.4,294.9786982
|
Clarke 1866,7008,6378206.4,294.9786982
|
||||||
Clarke 1880 (Palestine),7010,6378300.789,293.466
|
Clarke 1880 (Palestine),7010,6378300.789,293.466
|
||||||
Clarke 1880 (IGN),7011,6378249.2,293.466021
|
Clarke 1880 (IGN),7011,6378249.2,293.466021
|
||||||
@ -11,9 +12,17 @@ Everest 1830 (1937 Adjustment),7015,6377276.345,300.8017
|
|||||||
Everest 1830 Modified,7018,6377304.063,300.8017
|
Everest 1830 Modified,7018,6377304.063,300.8017
|
||||||
GRS 80,7019,6378137.0,298.257222101
|
GRS 80,7019,6378137.0,298.257222101
|
||||||
Helmert 1906,7020,6378200.0,298.3
|
Helmert 1906,7020,6378200.0,298.3
|
||||||
|
Indonesian National Spheroid,7021,6378160.0,298.247
|
||||||
International 1924,7022,6378388.0,297.0
|
International 1924,7022,6378388.0,297.0
|
||||||
Krassovsky 1940,7024,6378245.0,298.3
|
Krassovsky 1940,7024,6378245.0,298.3
|
||||||
|
War Office,7029,6378300.0,296.0
|
||||||
South American 1969,7036,6378160.0,298.25
|
South American 1969,7036,6378160.0,298.25
|
||||||
WGS 72,7043,6378135.0,298.26
|
WGS 72,7043,6378135.0,298.26
|
||||||
|
Everest 1830 (1962 Definition),7044,6377301.243,300.8017255
|
||||||
|
Everest 1830 (1975 Definition),7045,6377299.151,300.8017255
|
||||||
Bessel 1841 (Namibia),7046,6377483.865,299.1528128
|
Bessel 1841 (Namibia),7046,6377483.865,299.1528128
|
||||||
|
GRS 1967 Modified,7050,6378160.0,298.25
|
||||||
|
Danish 1876,7051,6377019.27,300.0
|
||||||
Hough 1960,7053,6378270.0,297.0
|
Hough 1960,7053,6378270.0,297.0
|
||||||
|
Clarke 1880 (international foot),7055,6378306.370,293.4663077
|
||||||
|
PZ-90,7054,6378136.0,298.257839303
|
||||||
|
|
498
pkg/csv/gcs.csv
498
pkg/csv/gcs.csv
@ -1,124 +1,374 @@
|
|||||||
Adindan,4201,6201,9122,7012,8901,9603,-162,-12,206
|
HD1909,3819,1024,9122,7004,8901,9607,595.48,121.69,515.35,-4.115,2.9383,-0.853,-3.408
|
||||||
Afgooye,4205,6205,9122,7024,8901,9603,-43,-163,45
|
TWD97,3824,1026,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Ain el Abd 1970,4204,6204,9122,7022,8901,9603,-150,-251,-2
|
IGRS,3889,1029,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Anna 1 Astro 1965,4708,6708,9122,7003,8901,9603,-491,-22,435
|
Hermannskogel,3906,1031,9122,7004,8901,9603,653,-212,449,,,,
|
||||||
Arc 1950,4209,6209,9122,7012,8901,9603,-143,-90,-294
|
MOLDREF99,4023,1032,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Arc 1960,4210,6210,9122,7012,8901,9603,-160,-8,-300
|
RGRDC 2005,4046,1033,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Ascension Island 1958,4712,6712,9122,7022,8901,9603,-207,107,52
|
SREF98,4075,1034,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Astro B4 Sorol Atoll,4707,6707,9122,7022,8901,9603,114,-116,-333
|
REGCAN95,4081,1035,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Astro Beacon 1945,4709,6709,9122,7022,8901,9603,145,75,-272
|
GGRS 87,4121,6121,9122,7019,8901,9603,-199.87,74.79,246.62,,,,
|
||||||
Astro DOS 71/4,4710,6710,9122,7022,8901,9603,-320,550,-494
|
Finland Hayford,4123,6123,9122,7022,8901,9603,-78,-231,-97,,,,
|
||||||
Astronomic Stn 1952,4711,6711,9122,7022,8901,9603,124,-234,-25
|
RT 90,4124,6124,9122,7004,8901,9603,498,-36,568,,,,
|
||||||
Australian Geodetic 1966,4202,6202,9122,7003,8901,9603,-133,-48,148
|
Samboja,4125,6125,9108,7004,8901,9603,-404.78,685.68,45.47,,,,
|
||||||
Australian Geodetic 1984,4203,6203,9122,7003,8901,9603,-134,-48,149
|
Tete,4127,6127,9122,7008,8901,9603,-80,-100,-228,,,,
|
||||||
Australian Geocentric 1994 (GDA94),4283,6283,9122,7019,8901,9603,0,0,0
|
Observatario,4129,6129,9122,7008,8901,9603,-132,-110,-335,,,,
|
||||||
Austrian,4312,6312,9122,7004,8901,9603,594,84,471
|
Moznet,4130,6130,9122,7030,8901,9607,0,0,0,0,0,0,0
|
||||||
Bellevue (IGN),4714,6714,9122,7022,8901,9603,-127,-769,472
|
Indian 1960,4131,6131,9122,7015,8901,9603,198,881,317,,,,
|
||||||
Bermuda 1957,4216,6216,9122,7008,8901,9603,-73,213,296
|
FD58,4132,6132,9122,7012,8901,9603,-241.54,-163.64,396.06,,,,
|
||||||
Bogota Observatory,4218,6218,9122,7022,8901,9603,307,304,-318
|
EST92,4133,6133,9122,7019,8901,9607,0.055,-0.541,-0.185,-0.0183,0.0003,0.007,-0.014
|
||||||
Campo Inchauspe,4221,6221,9122,7022,8901,9603,-148,136,90
|
PSD93,4134,6134,9122,7012,8901,9606,-180.624,-225.516,173.919,-0.81,-1.898,8.336,16.71006
|
||||||
Canton Astro 1966,4716,6716,9122,7022,8901,9603,298,-304,-375
|
Old Hawaiian,4135,6135,9122,7008,8901,9603,61,-285,-181,,,,
|
||||||
Cape,4222,6222,9122,7012,8901,9603,-136,-108,-292
|
Puerto Rico,4139,6139,9122,7008,8901,9603,11,72,-101,,,,
|
||||||
Cape Canaveral,4717,6717,9122,7008,8901,9603,-2,150,181
|
NAD83(CSRS98),4140,6140,9108,7019,8901,9603,0,0,0,,,,
|
||||||
Carthage,4223,6223,9122,7012,8901,9603,-263,6,431
|
Israel 1993,4141,6141,9122,7019,8901,9603,-48,55,52,,,,
|
||||||
CH-1903,4149,6149,9122,7004,8901,9603,674.374,15.056,405.343
|
Locodjo 1965,4142,6142,9122,7012,8901,9603,-125,53,467,,,,
|
||||||
Chatham 1971,4672,6672,9122,7022,8901,9603,175,-38,113
|
Abidjan 1987,4143,6143,9122,7012,8901,9603,-124.76,53,466.79,,,,
|
||||||
Chua Astro,4224,6224,9122,7022,8901,9603,-134,229,-29
|
Kalianpur 1937,4144,6144,9122,7015,8901,9603,214,804,268,,,,
|
||||||
Corrego Alegre,4225,6225,9122,7022,8901,9603,-206,172,-6
|
Kalianpur 1962,4145,6145,9122,7044,8901,9603,283,682,231,,,,
|
||||||
Djakarta (Batavia),4211,6211,9122,7004,8901,9603,-377,681,-50
|
Kalianpur 1975,4146,6146,9122,7045,8901,9603,295,736,257,,,,
|
||||||
DOS 1968,,,9122,7022,8901,9603,230,-199,-752
|
Hanoi 1972,4147,6147,9122,7024,8901,9603,-17.51,-108.32,-62.39,,,,
|
||||||
Easter Island 1967,4719,6719,9122,7022,8901,9603,211,147,111
|
Hartebeeshoek94,4148,6148,9122,7030,8901,9603,0,0,0,,,,
|
||||||
Egypt,4199,6199,9122,7022,8901,9603,-130,-117,-151
|
CH-1903,4149,6149,9122,7004,8901,9603,674.374,15.056,405.343,,,,
|
||||||
EST97,4180,6180,9122,7019,8901,9603,0,0,0
|
CH1903+,4150,6150,9122,7004,8901,9603,674.374,15.056,405.346,,,,
|
||||||
ETRS 89,4258,6258,9122,7019,8901,9603,0,0,0
|
CHTRF95,4151,6151,9122,7019,8901,9603,0,0,0,,,,
|
||||||
European 1950,4230,6230,9122,7022,8901,9603,-87,-98,-121
|
NAD83(HARN),4152,6152,9122,7019,8901,9603,0,0,0,,,,
|
||||||
European 1950 (Mean France),,,9122,7022,8901,9603,-87,-96,-120
|
Rassadiran,4153,6153,9122,7022,8901,9603,-133.63,-157.5,-158.62,,,,
|
||||||
European 1950 (Spain and Portugal),,,9122,7022,8901,9603,-84,-107,-120
|
ED50(ED77),4154,6154,9122,7022,8901,9603,-117,-132,-164,,,,
|
||||||
European 1979,4668,6668,9122,7022,8901,9603,-86,-98,-119
|
Dabola 1981,4155,6155,9122,7011,8901,9603,-83,37,124,,,,
|
||||||
Finland Hayford,4123,6123,9122,7022,8901,9603,-78,-231,-97
|
S-JTSK,4156,6156,9122,7004,8901,9603,589,76,480,,,,
|
||||||
Gandajika Base,4233,6233,9122,7022,8901,9603,-133,-321,50
|
Naparima 1955,4158,6158,9122,7022,8901,9603,-0.465,372.095,171.736,,,,
|
||||||
Geodetic Datum 1949,4272,6272,9122,7022,8901,9603,84,-22,209
|
ELD79,4159,6159,9122,7022,8901,9603,-115.8543,-99.0583,-152.4616,,,,
|
||||||
GGRS 87,4121,6121,9122,7019,8901,9603,-199.87,74.79,246.62
|
Pampa del Castillo,4161,6161,9122,7022,8901,9603,27.5,14,186.4,,,,
|
||||||
Guam 1963,4675,6675,9122,7008,8901,9603,-100,-248,259
|
Yemen NGN96,4163,6163,9122,7030,8901,9603,0,0,0,,,,
|
||||||
GUX 1 Astro,4718,6718,9122,7022,8901,9603,252,-209,-751
|
South Yemen,4164,6164,9122,7024,8901,9603,-76,-138,67,,,,
|
||||||
Hartebeeshoek94,4148,6148,9122,7030,8901,9603,0,0,0
|
Bissau,4165,6165,9122,7022,8901,9603,-173,253,27,,,,
|
||||||
Hermannskogel,3906,1031,9122,7004,8901,9603,653,-212,449
|
Korean 1995,4166,6166,9122,7030,8901,9603,0,0,0,,,,
|
||||||
Hjorsey 1955,4658,6658,9122,7022,8901,9603,-73,46,-86
|
NZGD2000,4167,6167,9122,7030,8901,9603,0,0,0,,,,
|
||||||
Hong Kong 1963,4739,6739,9122,7022,8901,9603,-156,-271,-189
|
Accra,4168,6168,9122,7029,8901,9603,-199,32,322,,,,
|
||||||
Hu-Tzu-Shan,4236,6236,9122,7022,8901,9603,-634,-549,-201
|
American Samoa 1962,4169,6169,9122,7008,8901,9603,-115,118,426,,,,
|
||||||
Indian Bangladesh,4682,6682,9122,7015,8901,9603,289,734,257
|
SIRGAS 1995,4170,6170,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Indian Thailand,4240,6240,9122,7015,8901,9603,214,836,303
|
RGF93,4171,6171,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Israeli,4281,6281,9122,7010,8901,9603,-235,-85,264
|
POSGAR,4172,6172,9108,7019,8901,9603,0,0,0,,,,
|
||||||
Ireland 1965,4299,6299,9122,7002,8901,9603,506,-122,611
|
IRENET95,4173,6173,9122,7019,8901,9603,0,0,0,,,,
|
||||||
ISTS 073 Astro 1969,4724,6724,9122,7022,8901,9603,208,-435,-229
|
Sierra Leone 1968,4175,6175,9122,7012,8901,9603,-88,4,101,,,,
|
||||||
Johnston Island,4725,6725,9122,7022,8901,9603,191,-77,-204
|
Australian Antarctic,4176,6176,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Kandawala,4244,6244,9122,7015,8901,9603,-97,787,86
|
S42 (83),4178,6178,9122,7024,8901,9603,26,-121,-78,,,,
|
||||||
Kerguelen Island,4698,6698,9122,7022,8901,9603,145,-187,103
|
S42,4179,6179,9122,7024,8901,9603,28,-121,-77,,,,
|
||||||
Kertau 1948,4245,6245,9122,7018,8901,9603,-11,851,5
|
EST97,4180,6180,9122,7019,8901,9603,0,0,0,,,,
|
||||||
L.C. 5 Astro,4726,6726,9122,7008,8901,9603,42,124,147
|
Luxembourg 1930,4181,6181,9122,7022,8901,9607,-189.6806,18.3463,-42.7695,0.33746,3.09264,-2.53861,0.4598
|
||||||
Liberia 1964,4251,6251,9122,7012,8901,9603,-90,40,88
|
Observatorio 1966,4182,6182,9122,7022,8901,9603,-425,-169,81,,,,
|
||||||
Luzon Mindanao,,,9122,7008,8901,9603,-133,-79,-72
|
Southwest Base,4183,6183,9122,7022,8901,9603,-104,167,-38,,,,
|
||||||
Luzon Philippines,4253,6253,9122,7008,8901,9603,-133,-77,-51
|
Sao Braz,4184,6184,9122,7022,8901,9603,-203,141,53,,,,
|
||||||
Mahe 1971,4256,6256,9122,7012,8901,9603,41,-220,-134
|
OSNI 1952,4188,6188,9122,7001,8901,9606,482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15
|
||||||
Marco Astro,4616,6616,9122,7022,8901,9603,-289,-124,60
|
REGVEN,4189,6189,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Massawa,4262,6262,9122,7004,8901,9603,639,405,60
|
POSGAR 98,4190,6190,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Merchich,4261,6261,9122,7012,8901,9603,31,146,47
|
Albanian 1987,4191,6191,9122,7024,8901,9607,-44.183,-0.58,-38.489,-2.3867,-2.7072,3.5196,-8.2703
|
||||||
Midway Astro 1961,4727,6727,9122,7022,8901,9603,912,-58,1227
|
Douala 1948,4192,6192,9122,7022,8901,9603,-206.1,-174.7,-87.7,,,,
|
||||||
Minna,4263,6263,9122,7012,8901,9603,-92,-93,122
|
Manoca 1962,4193,6193,9122,7011,8901,9603,-70.9,-151.8,-41.4,,,,
|
||||||
NAD27 Alaska,,,9122,7008,8901,9603,-5,135,172
|
Qornoq 1927,4194,6194,9122,7022,8901,9603,164,138,-189,,,,
|
||||||
NAD27 Bahamas,,,9122,7008,8901,9603,-4,154,178
|
Scoresbysund 1952,4195,6195,9122,7022,8901,9606,105,326,-102.5,0,0,0.814,-0.6
|
||||||
NAD27 Canada,,,9122,7008,8901,9603,-10,158,187
|
Ammassalik 1958,4196,6196,9122,7022,8901,9606,-45,417,-3.5,0,0,0.814,-0.6
|
||||||
NAD27 Canal Zone,,,9122,7008,8901,9603,0,125,201
|
Egypt,4199,6199,9122,7022,8901,9603,-130,-117,-151,,,,
|
||||||
NAD27 Caribbean,,,9122,7008,8901,9603,-3,142,183
|
Pulkovo 1995,4200,6200,9122,7024,8901,9607,24.47,-130.89,-81.56,0,0,-0.13,-0.22
|
||||||
NAD27 Central,,,9122,7008,8901,9603,0,125,194
|
Adindan,4201,6201,9122,7012,8901,9603,-162,-12,206,,,,
|
||||||
NAD27 CONUS,4267,6267,9122,7008,8901,9603,-8,160,176
|
Australian Geodetic 1966,4202,6202,9122,7003,8901,9603,-133,-48,148,,,,
|
||||||
NAD27 Cuba,,,9122,7008,8901,9603,-9,152,178
|
Australian Geodetic 1984,4203,6203,9122,7003,8901,9603,-134,-48,149,,,,
|
||||||
NAD27 Greenland,,,9122,7008,8901,9603,11,114,195
|
Ain el Abd 1970,4204,6204,9122,7022,8901,9603,-150,-251,-2,,,,
|
||||||
NAD27 Mexico,,,9122,7008,8901,9603,-12,130,190
|
Afgooye,4205,6205,9122,7024,8901,9603,-43,-163,45,,,,
|
||||||
NAD27 San Salvador,,,9122,7008,8901,9603,1,140,165
|
Lisbon,4207,6207,9122,7022,8901,9603,-304.046,-60.576,103.64,,,,
|
||||||
NAD83,4269,6269,9122,7019,8901,9603,0,0,0
|
Aratu,4208,6208,9122,7022,8901,9603,-151.99,287.04,-147.45,,,,
|
||||||
Nahrwn Masirah Ilnd,,,9122,7012,8901,9603,-247,-148,369
|
Arc 1950,4209,6209,9122,7012,8901,9603,-143,-90,-294,,,,
|
||||||
Nahrwn Saudi Arbia,,,9122,7012,8901,9603,-231,-196,482
|
Arc 1960,4210,6210,9122,7012,8901,9603,-160,-8,-300,,,,
|
||||||
Nahrwn United Arab,4270,6270,9122,7012,8901,9603,-249,-156,381
|
Djakarta (Batavia),4211,6211,9122,7004,8901,9603,-377,681,-50,,,,
|
||||||
Naparima BWI,4271,6271,9122,7022,8901,9603,-2,374,172
|
Barbados 1938,4212,6212,9122,7012,8901,9603,31.95,300.99,419.19,,,,
|
||||||
NGO1948,4273,6273,9122,7005,8901,9603,315,-217,528
|
Beduaram,4213,6213,9122,7011,8901,9603,-106,-87,188,,,,
|
||||||
NTF France,4275,6275,9122,7011,8901,9603,-168,-60,320
|
Beijing 1954,4214,6214,9122,7024,8901,9603,15.8,-154.4,-82.3,,,,
|
||||||
Norsk,4817,6817,9122,7005,8913,9603,278,93,474
|
Bermuda 1957,4216,6216,9122,7008,8901,9603,-73,213,296,,,,
|
||||||
NZGD1949,4272,6272,9122,7022,8901,9603,84,-22,209
|
Bogota Observatory,4218,6218,9122,7022,8901,9603,307,304,-318,,,,
|
||||||
NZGD2000,4167,6167,9122,7030,8901,9603,0,0,0
|
Bukit Rimpah,4219,6219,9122,7004,8901,9603,-384,664,-48,,,,
|
||||||
Observatorio 1966,4182,6182,9122,7022,8901,9603,-425,-169,81
|
Camacupa,4220,6220,9122,7012,8901,9603,-50.9,-347.6,-231,,,,
|
||||||
Old Egyptian,4229,6229,9122,7020,8901,9603,-130,110,-13
|
Campo Inchauspe,4221,6221,9122,7022,8901,9603,-148,136,90,,,,
|
||||||
Old Hawaiian,4135,6135,9122,7008,8901,9603,61,-285,-181
|
Cape,4222,6222,9122,7012,8901,9603,-136,-108,-292,,,,
|
||||||
Oman,4232,6232,9122,7012,8901,9603,-346,-1,224
|
Carthage,4223,6223,9122,7012,8901,9603,-263,6,431,,,,
|
||||||
Ord Srvy Grt Britn,4277,6277,9122,7001,8901,9603,375,-111,431
|
Chua Astro,4224,6224,9122,7022,8901,9603,-134,229,-29,,,,
|
||||||
Pico De Las Nieves,4728,6728,9122,7022,8901,9603,-307,-92,127
|
Corrego Alegre,4225,6225,9122,7022,8901,9603,-206,172,-6,,,,
|
||||||
Pitcairn Astro 1967,4729,6729,9122,7022,8901,9603,185,165,42
|
Deir ez Zor,4227,6227,9122,7011,8901,9603,-190.421,8.532,238.69,,,,
|
||||||
Potsdam Rauenberg DHDN,4314,6314,9122,7004,8901,9603,606,23,413
|
Old Egyptian,4229,6229,9122,7020,8901,9603,-130,110,-13,,,,
|
||||||
Prov So Amrican 1956,4248,6248,9122,7022,8901,9603,-288,175,-376
|
European 1950,4230,6230,9122,7022,8901,9603,-87,-98,-121,,,,
|
||||||
Prov So Chilean 1963,4254,6254,9122,7022,8901,9603,16,196,93
|
ED87,4231,6231,9122,7022,8901,9606,-83.11,-97.38,-117.22,0.005693,-0.044698,0.044285,0.1218
|
||||||
Puerto Rico,4139,6139,9122,7008,8901,9603,11,72,-101
|
Oman,4232,6232,9122,7012,8901,9603,-346,-1,224,,,,
|
||||||
Pulkovo 1942 (1),4284,6284,9122,7024,8901,9603,28,-130,-95
|
Gandajika Base,4233,6233,9122,7022,8901,9603,-133,-321,50,,,,
|
||||||
Pulkovo 1942 (2),,,9122,7024,8901,9603,28,-130,-95
|
Hu-Tzu-Shan,4236,6236,9122,7022,8901,9603,-634,-549,-201,,,,
|
||||||
Qatar National,4285,6285,9122,7022,8901,9603,-128,-283,22
|
HD72,4237,6237,9122,7036,8901,9603,52.17,-71.82,-14.9,,,,
|
||||||
Qornoq,4287,6287,9108,7022,8901,9603,164,138,-189
|
ID74,4238,6238,9122,7021,8901,9603,-24,-15,5,,,,
|
||||||
Reunion,4626,6626,9122,7022,8901,9603,94,-948,-1262
|
Indian 1954,4239,6239,9122,7015,8901,9603,217,823,299,,,,
|
||||||
Rijksdriehoeksmeting,4289,6289,9122,7004,8901,9603,593,26,478
|
Indian Thailand,4240,6240,9122,7015,8901,9603,214,836,303,,,,
|
||||||
Rome 1940,4806,6806,9122,7022,8906,9603,-225,-65,9
|
JAD69,4242,6242,9122,7008,8901,9603,70,207,389.5,,,,
|
||||||
RT 90,4124,6124,9122,7004,8901,9603,498,-36,568
|
Kandawala,4244,6244,9122,7015,8901,9603,-97,787,86,,,,
|
||||||
S42,4179,6179,9122,7024,8901,9603,28,-121,-77
|
Kertau 1948,4245,6245,9122,7018,8901,9603,-11,851,5,,,,
|
||||||
S42 (83),4178,6178,9122,7024,8901,9603,26,-121,-78
|
KOC,4246,6246,9122,7012,8901,9603,-294.7,-200.1,525.5,,,,
|
||||||
Santo (DOS),4730,6730,9122,7022,8901,9603,170,42,84
|
La Canoa,4247,6247,9122,7022,8901,9603,-273.5,110.6,-357.9,,,,
|
||||||
Sao Braz,4184,6184,9122,7022,8901,9603,-203,141,53
|
Prov So Amrican 1956,4248,6248,9122,7022,8901,9603,-288,175,-376,,,,
|
||||||
Sapper Hill 1943,4292,6292,9122,7022,8901,9603,-355,16,74
|
Leigon,4250,6250,9122,7012,8901,9603,-130,29,364,,,,
|
||||||
Schwarzeck,4293,6293,9122,7046,8901,9603,616,97,-251
|
Liberia 1964,4251,6251,9122,7012,8901,9603,-90,40,88,,,,
|
||||||
South American 1969,4291,6291,9108,7036,8901,9603,-57,1,-41
|
Luzon Philippines,4253,6253,9122,7008,8901,9603,-133,-77,-51,,,,
|
||||||
Southeast Base,4615,6615,9122,7022,8901,9603,-499,-249,314
|
Prov So Chilean 1963,4254,6254,9122,7022,8901,9603,16,196,93,,,,
|
||||||
Southwest Base,4183,6183,9122,7022,8901,9603,-104,167,-38
|
Herat North,4255,6255,9122,7022,8901,9603,-333,-222,114,,,,
|
||||||
Timbalai 1948,4298,6298,9122,7015,8901,9603,-689,691,-46
|
Mahe 1971,4256,6256,9122,7012,8901,9603,41,-220,-134,,,,
|
||||||
Tokyo,4301,6301,9122,7004,8901,9603,-128,481,664
|
Makassar,4257,6257,9122,7004,8901,9603,-587.8,519.75,145.76,,,,
|
||||||
Tristan Astro 1968,4734,6734,9122,7022,8901,9603,-632,438,-609
|
ETRS 89,4258,6258,9122,7019,8901,9603,0,0,0,,,,
|
||||||
Viti Levu 1916,4731,6731,9122,7012,8901,9603,51,391,-36
|
Malongo 1987,4259,6259,9122,7022,8901,9603,-254.1,-5.36,-100.29,,,,
|
||||||
Wake-Eniwetok 1960,4732,6732,9122,7053,8901,9603,101,52,-39
|
Manoca,4260,6260,9108,7012,8901,9603,-70.9,-151.8,-41.4,,,,
|
||||||
WGS 72,4322,6322,9122,7043,8901,9603,0,0,5
|
Merchich,4261,6261,9122,7012,8901,9603,31,146,47,,,,
|
||||||
Yacare,4309,6309,9122,7022,8901,9603,-155,171,37
|
Massawa,4262,6262,9122,7004,8901,9603,639,405,60,,,,
|
||||||
Zanderij,4311,6311,9122,7022,8901,9603,-265,120,-358
|
Minna,4263,6263,9122,7012,8901,9603,-92,-93,122,,,,
|
||||||
|
Mhast,4264,6264,9122,7022,8901,9603,-252.95,-4.11,-96.38,,,,
|
||||||
|
Monte Mario,4265,6265,9122,7022,8901,9606,-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68
|
||||||
|
M'poraloko,4266,6266,9122,7011,8901,9603,-74,-130,42,,,,
|
||||||
|
NAD27 CONUS,4267,6267,9122,7008,8901,9603,-8,160,176,,,,
|
||||||
|
NAD83,4269,6269,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Nahrwn United Arab,4270,6270,9122,7012,8901,9603,-249,-156,381,,,,
|
||||||
|
Naparima BWI,4271,6271,9122,7022,8901,9603,-2,374,172,,,,
|
||||||
|
Geodetic Datum 1949,4272,6272,9122,7022,8901,9603,84,-22,209,,,,
|
||||||
|
NZGD1949,4272,6272,9122,7022,8901,9603,84,-22,209,,,,
|
||||||
|
NGO1948,4273,6273,9122,7005,8901,9603,315,-217,528,,,,
|
||||||
|
Datum 73,4274,6274,9122,7022,8901,9603,-223.237,110.193,36.649,,,,
|
||||||
|
NTF France,4275,6275,9122,7011,8901,9603,-168,-60,320,,,,
|
||||||
|
Ord Srvy Grt Britn,4277,6277,9122,7001,8901,9603,375,-111,431,,,,
|
||||||
|
Israeli,4281,6281,9122,7010,8901,9603,-235,-85,264,,,,
|
||||||
|
Pointe Noire,4282,6282,9122,7011,8901,9603,-148,51,-291,,,,
|
||||||
|
Australian Geocentric 1994 (GDA94),4283,6283,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Pulkovo 1942 (1),4284,6284,9122,7024,8901,9603,28,-130,-95,,,,
|
||||||
|
Qatar National,4285,6285,9122,7022,8901,9603,-128,-283,22,,,,
|
||||||
|
Qornoq,4287,6287,9108,7022,8901,9603,164,138,-189,,,,
|
||||||
|
Rijksdriehoeksmeting,4289,6289,9122,7004,8901,9603,593,26,478,,,,
|
||||||
|
South American 1969,4291,6291,9108,7036,8901,9603,-57,1,-41,,,,
|
||||||
|
Sapper Hill 1943,4292,6292,9122,7022,8901,9603,-355,16,74,,,,
|
||||||
|
Schwarzeck,4293,6293,9122,7046,8901,9603,616,97,-251,,,,
|
||||||
|
Segora,4294,6294,9108,7004,8901,9603,-403,684,41,,,,
|
||||||
|
Tananarive,4297,6297,9122,7022,8901,9603,-189,-242,-91,,,,
|
||||||
|
Timbalai 1948,4298,6298,9122,7015,8901,9603,-689,691,-46,,,,
|
||||||
|
Ireland 1965,4299,6299,9122,7002,8901,9603,506,-122,611,,,,
|
||||||
|
TM75,4300,6300,9122,7002,8901,9606,482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15
|
||||||
|
Tokyo,4301,6301,9122,7004,8901,9603,-128,481,664,,,,
|
||||||
|
Trinidad 1903,4302,6302,9122,7007,8901,9603,-61.702,284.488,472.052,,,,
|
||||||
|
Voirol 1875,4304,6304,9122,7011,8901,9603,-73,-247,227,,,,
|
||||||
|
Nord Sahara 1959,4307,6307,9122,7012,8901,9606,-209.3622,-87.8162,404.6198,0.0046,3.4784,0.5805,-1.4547
|
||||||
|
Yacare,4309,6309,9122,7022,8901,9603,-155,171,37,,,,
|
||||||
|
Yoff,4310,6310,9122,7011,8901,9603,-30,190,89,,,,
|
||||||
|
Zanderij,4311,6311,9122,7022,8901,9603,-265,120,-358,,,,
|
||||||
|
Austrian,4312,6312,9122,7004,8901,9603,594,84,471,,,,
|
||||||
|
Belge 1972,4313,6313,9122,7022,8901,9607,-106.8686,52.2978,-103.7239,-0.3366,0.457,-1.8422,-1.2747
|
||||||
|
Potsdam Rauenberg DHDN,4314,6314,9122,7004,8901,9603,606,23,413,,,,
|
||||||
|
Conakry 1905,4315,6315,9122,7011,8901,9603,-23,259,-9,,,,
|
||||||
|
Dealul Piscului 1930,4316,6316,9122,7022,8901,9603,103.25,-100.4,-307.19,,,,
|
||||||
|
Dealul Piscului 1970,4317,6317,9122,7024,8901,9603,28,-121,-77,,,,
|
||||||
|
NGN,4318,6318,9122,7030,8901,9603,-3.2,-5.7,2.8,,,,
|
||||||
|
KUDAMS,4319,6319,9122,7019,8901,9603,-20.8,11.3,2.4,,,,
|
||||||
|
WGS 72,4322,6322,9122,7043,8901,9603,0,0,5,,,,
|
||||||
|
WGS 72BE,4324,6324,9122,7043,8901,9606,0,0,1.9,0,0,0.814,-0.38
|
||||||
|
RGSPM06,4463,1038,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
RGM04,4470,1036,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Cadastre 1997,4475,1037,9122,7022,8901,9603,-381.788,-57.501,-256.673,,,,
|
||||||
|
Mexico ITRF92,4483,1042,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
RRAF 1991,4558,1047,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Antigua 1943,4601,6601,9122,7012,8901,9603,-255,-15,71,,,,
|
||||||
|
Dominica 1945,4602,6602,9122,7012,8901,9603,725,685,536,,,,
|
||||||
|
Grenada 1953,4603,6603,9122,7012,8901,9603,72,213.7,93,,,,
|
||||||
|
Montserrat 1958,4604,6604,9122,7012,8901,9603,174,359,365,,,,
|
||||||
|
St. Kitts 1955,4605,6605,9122,7012,8901,9603,9,183,236,,,,
|
||||||
|
St. Lucia 1955,4606,6606,9122,7012,8901,9603,-149,128,296,,,,
|
||||||
|
St. Vincent 1945,4607,6607,9122,7012,8901,9603,195.671,332.517,274.607,,,,
|
||||||
|
Hong Kong 1980,4611,6611,9122,7022,8901,9606,-162.619,-276.959,-161.764,0.067753,-2.243649,-1.158827,-1.094246
|
||||||
|
JGD2000,4612,6612,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Segara,4613,6613,9122,7004,8901,9603,-403,684,41,,,,
|
||||||
|
QND95,4614,6614,9122,7022,8901,9606,-119.4248,-303.65872,-11.00061,1.164298,0.174458,1.096259,3.657065
|
||||||
|
Southeast Base,4615,6615,9122,7022,8901,9603,-499,-249,314,,,,
|
||||||
|
Marco Astro,4616,6616,9122,7022,8901,9603,-289,-124,60,,,,
|
||||||
|
NAD83(CSRS),4617,6140,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
SAD69,4618,6618,9122,7050,8901,9603,-66.87,4.37,-38.52,,,,
|
||||||
|
SWEREF99,4619,6619,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Point 58,4620,6620,9122,7012,8901,9603,-106,-129,165,,,,
|
||||||
|
Fort Marigot,4621,6621,9122,7022,8901,9603,137,248,-430,,,,
|
||||||
|
Guadeloupe 1948,4622,6622,9122,7022,8901,9603,-467,-16,-300,,,,
|
||||||
|
CSG67,4623,6623,9122,7022,8901,9603,-186,230,110,,,,
|
||||||
|
RGFG95,4624,6624,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Martinique 1938,4625,6625,9122,7022,8901,9603,186,482,151,,,,
|
||||||
|
Reunion,4626,6626,9122,7022,8901,9603,94,-948,-1262,,,,
|
||||||
|
RGR92,4627,6627,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Tahiti 52,4628,6628,9122,7022,8901,9603,162,117,154,,,,
|
||||||
|
Tahaa 54,4629,6629,9122,7022,8901,9607,72.438,345.918,79.486,-1.6045,-0.8823,-0.5565,1.3746
|
||||||
|
IGN72 Nuku Hiva,4630,6630,9122,7022,8901,9603,84,274,65,,,,
|
||||||
|
K0 1949,4631,6631,9122,7022,8901,9603,145,-187,103,,,,
|
||||||
|
Combani 1950,4632,6632,9122,7022,8901,9603,-382,-59,-262,,,,
|
||||||
|
IGN56 Lifou,4633,6633,9122,7022,8901,9603,335.47,222.58,-230.94,,,,
|
||||||
|
IGN72 Grand Terre,4634,6634,9108,7022,8901,9603,-13,-348,292,,,,
|
||||||
|
ST87 Ouvea,4635,6635,9122,7022,8901,9606,-122.383,-188.696,103.344,3.5107,-4.9668,-5.7047,4.4798
|
||||||
|
Petrels 1972,4636,6636,9122,7022,8901,9603,365,194,166,,,,
|
||||||
|
Perroud 1950,4637,6637,9122,7022,8901,9603,325,154,172,,,,
|
||||||
|
Saint Pierre et Miquelon 1950,4638,6638,9122,7008,8901,9603,30,430,368,,,,
|
||||||
|
MOP78,4639,6639,9122,7022,8901,9603,253,-132,-127,,,,
|
||||||
|
RRAF 1991,4640,6640,9122,7030,8901,9603,0,0,0,,,,
|
||||||
|
IGN53 Mare,4641,6641,9122,7022,8901,9603,287.58,177.78,-135.41,,,,
|
||||||
|
ST84 Ile des Pins,4642,6642,9122,7022,8901,9603,-13,-348,292,,,,
|
||||||
|
ST71 Belep,4643,6643,9122,7022,8901,9606,-480.26,-438.32,-643.429,16.3119,20.1721,-4.0349,-111.7002
|
||||||
|
NEA74 Noumea,4644,6644,9122,7022,8901,9603,-10.18,-350.43,291.37,,,,
|
||||||
|
RGNC 1991,4645,6645,9122,7022,8901,9603,0,0,0,,,,
|
||||||
|
Grand Comoros,4646,6646,9122,7022,8901,9603,-963,510,-359,,,,
|
||||||
|
Reykjavik 1900,4657,6657,9122,7051,8901,9603,-28,199,5,,,,
|
||||||
|
Hjorsey 1955,4658,6658,9122,7022,8901,9603,-73,46,-86,,,,
|
||||||
|
ISN93,4659,6659,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Helle 1954,4660,6660,9122,7022,8901,9606,982.6087,552.753,-540.873,6.6816266,-31.6114924,-19.84816,16.805
|
||||||
|
LKS92,4661,6661,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
IGN72 Grande Terre,4662,6634,9122,7022,8901,9603,-11.64,-348.6,291.98,,,,
|
||||||
|
Porto Santo 1995,4663,6663,9122,7022,8901,9603,-502.862,-247.438,312.724,,,,
|
||||||
|
Azores Oriental 1995,4664,6664,9122,7022,8901,9603,-204.619,140.176,55.226,,,,
|
||||||
|
Azores Central 1995,4665,6665,9122,7022,8901,9603,-106.226,166.366,-37.893,,,,
|
||||||
|
Lisbon 1890,4666,6666,9122,7004,8901,9603,508.088,-191.042,565.223,,,,
|
||||||
|
IKBD-92,4667,6667,9122,7030,8901,9603,0,0,0,,,,
|
||||||
|
European 1979,4668,6668,9122,7022,8901,9603,-86,-98,-119,,,,
|
||||||
|
LKS94,4669,6126,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
IGM95,4670,6670,9122,7030,8901,9603,0,0,0,,,,
|
||||||
|
Chatham 1971,4672,6672,9122,7022,8901,9603,175,-38,113,,,,
|
||||||
|
Chatham Islands 1979,4673,6673,9122,7022,8901,9607,174.05,-25.49,112.57,0,0,-0.554,0.2263
|
||||||
|
SIRGAS 2000,4674,6674,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Guam 1963,4675,6675,9122,7008,8901,9603,-100,-248,259,,,,
|
||||||
|
Lao 1997,4678,6678,9122,7024,8901,9603,44.585,-131.212,-39.544,,,,
|
||||||
|
Jouik 1961,4679,6679,9122,7012,8901,9603,-80.01,253.26,291.19,,,,
|
||||||
|
Nouakchott 1965,4680,6680,9122,7012,8901,9603,124.5,-63.5,-281,,,,
|
||||||
|
Indian Bangladesh,4682,6682,9122,7015,8901,9603,289,734,257,,,,
|
||||||
|
PRS92,4683,6683,9122,7008,8901,9607,-127.62,-67.24,-47.04,3.068,-4.903,-1.578,-1.06
|
||||||
|
Gan 1970,4684,6684,9122,7022,8901,9603,-133,-321,50,,,,
|
||||||
|
MAGNA-SIRGAS,4686,6686,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
RGPF,4687,6687,9122,7019,8901,9607,0.072,-0.507,-0.245,0.0183,-0.0003,0.007,-0.0093
|
||||||
|
Fatu Iva 72,4688,6688,9122,7022,8901,9607,347.103,1078.125,2623.922,33.8875,-70.6773,9.3943,186.074
|
||||||
|
IGN63 Hiva Oa,4689,6689,9122,7022,8901,9607,410.721,55.049,80.746,-2.5779,-2.3514,-0.6664,17.3311
|
||||||
|
Tahiti 79,4690,6690,9122,7022,8901,9607,221.525,152.948,176.768,2.3847,1.3896,0.877,11.4741
|
||||||
|
Moorea 87,4691,6691,9122,7022,8901,9607,215.525,149.593,176.229,3.2624,1.692,1.1571,10.4773
|
||||||
|
Maupiti 83,4692,6692,9122,7022,8901,9603,217.037,86.959,23.956,,,,
|
||||||
|
Nakhl-e Ghanem,4693,6693,9122,7030,8901,9603,0,-0.15,0.68,,,,
|
||||||
|
POSGAR 94,4694,6694,9122,7030,8901,9603,0,0,0,,,,
|
||||||
|
Katanga 1955,4695,6695,9122,7008,8901,9603,-103.746,-9.614,-255.95,,,,
|
||||||
|
Kerguelen Island,4698,6698,9122,7022,8901,9603,145,-187,103,,,,
|
||||||
|
Le Pouce 1934,4699,6699,9122,7012,8901,9603,-770.1,158.4,-498.2,,,,
|
||||||
|
IGCB 1955,4701,6701,9122,7012,8901,9603,-79.9,-158,-168.9,,,,
|
||||||
|
Mauritania 1999,4702,6702,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Egypt Gulf of Suez S-650 TL,4706,6706,9122,7020,8901,9603,-146.21,112.63,4.05,,,,
|
||||||
|
Astro B4 Sorol Atoll,4707,6707,9122,7022,8901,9603,114,-116,-333,,,,
|
||||||
|
Anna 1 Astro 1965,4708,6708,9122,7003,8901,9603,-491,-22,435,,,,
|
||||||
|
Astro Beacon 1945,4709,6709,9122,7022,8901,9603,145,75,-272,,,,
|
||||||
|
Astro DOS 71/4,4710,6710,9122,7022,8901,9603,-320,550,-494,,,,
|
||||||
|
Astronomic Stn 1952,4711,6711,9122,7022,8901,9603,124,-234,-25,,,,
|
||||||
|
Ascension Island 1958,4712,6712,9122,7022,8901,9603,-207,107,52,,,,
|
||||||
|
Ayabelle Lighthouse,4713,6713,9122,7012,8901,9603,-77,-128,142,,,,
|
||||||
|
Bellevue (IGN),4714,6714,9122,7022,8901,9603,-127,-769,472,,,,
|
||||||
|
Camp Area Astro,4715,6715,9122,7022,8901,9603,-104,-129,239,,,,
|
||||||
|
Canton Astro 1966,4716,6716,9122,7022,8901,9603,298,-304,-375,,,,
|
||||||
|
Cape Canaveral,4717,6717,9122,7008,8901,9603,-2,150,181,,,,
|
||||||
|
GUX 1 Astro,4718,6718,9122,7022,8901,9603,252,-209,-751,,,,
|
||||||
|
Easter Island 1967,4719,6719,9122,7022,8901,9603,211,147,111,,,,
|
||||||
|
Fiji 1986,4720,6720,9122,7043,8901,9606,0,0,4.5,0,0,0.554,0.2263
|
||||||
|
Fiji 1956,4721,6721,9122,7022,8901,9603,265.025,384.929,-194.046,,,,
|
||||||
|
South Georgia 1968,4722,6722,9122,7022,8901,9603,-794,119,-298,,,,
|
||||||
|
GCGD59,4723,6723,9122,7008,8901,9607,-179.483,-69.379,-27.584,7.862,-8.163,-6.042,-13.925
|
||||||
|
ISTS 073 Astro 1969,4724,6724,9122,7022,8901,9603,208,-435,-229,,,,
|
||||||
|
Johnston Island,4725,6725,9122,7022,8901,9603,191,-77,-204,,,,
|
||||||
|
L.C. 5 Astro,4726,6726,9122,7008,8901,9603,42,124,147,,,,
|
||||||
|
Midway Astro 1961,4727,6727,9122,7022,8901,9603,912,-58,1227,,,,
|
||||||
|
Pico De Las Nieves,4728,6728,9122,7022,8901,9603,-307,-92,127,,,,
|
||||||
|
Pitcairn Astro 1967,4729,6729,9122,7022,8901,9603,185,165,42,,,,
|
||||||
|
Santo (DOS),4730,6730,9122,7022,8901,9603,170,42,84,,,,
|
||||||
|
Viti Levu 1916,4731,6731,9122,7012,8901,9603,51,391,-36,,,,
|
||||||
|
Wake-Eniwetok 1960,4732,6732,9122,7053,8901,9603,101,52,-39,,,,
|
||||||
|
Wake Island 1952,4733,6733,9122,7022,8901,9603,276,-57,149,,,,
|
||||||
|
Tristan Astro 1968,4734,6734,9122,7022,8901,9603,-632,438,-609,,,,
|
||||||
|
Kusaie 1951,4735,6735,9122,7022,8901,9603,647,1777,-1124,,,,
|
||||||
|
Deception Island,4736,6736,9122,7012,8901,9603,260,12,-147,,,,
|
||||||
|
Korea 2000,4737,6737,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Hong Kong 1963,4739,6739,9122,7022,8901,9603,-156,-271,-189,,,,
|
||||||
|
PZ-90,4740,6740,9122,7054,8901,9607,0,0,1.5,0,0,-0.076,0
|
||||||
|
Karbala 1979,4743,6743,9122,7012,8901,9603,70.995,-335.916,262.898,,,,
|
||||||
|
Nahrwan 1934,4744,6744,9122,7012,8901,9603,-242.2,-144.9,370.3,,,,
|
||||||
|
GR96,4747,6747,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Vanua Levu 1915,4748,6748,9122,7055,8901,9603,51,391,-36,,,,
|
||||||
|
RGNC91-93,4749,6749,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
ST87 Ouvea,4750,6750,9122,7030,8901,9603,-56.263,16.136,-22.856,,,,
|
||||||
|
Viti Levu 1912,4752,6752,9122,7055,8901,9603,98,390,-22,,,,
|
||||||
|
LGD2006,4754,6754,9122,7022,8901,9603,-208.4058,-109.8777,-2.5764,,,,
|
||||||
|
DGN95,4755,6755,9122,7030,8901,9603,0,0,0,,,,
|
||||||
|
VN-2000,4756,6756,9122,7030,8901,9607,-191.90441429,-39.30318279,-111.45032835,-0.00928836,0.01975479,-0.00427372,0.252906278
|
||||||
|
JAD2001,4758,6758,9122,7030,8901,9603,0,0,0,,,,
|
||||||
|
NAD83(NSRS2007),4759,6759,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
HTRS96,4761,6761,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
BDA2000,4762,6762,9122,7030,8901,9603,0,0,0,,,,
|
||||||
|
Pitcairn 2006,4763,6763,9122,7030,8901,9603,0,0,0,,,,
|
||||||
|
RSRGD2000,4764,6764,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Slovenia 1996,4765,6765,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Bern 1898 (Bern),4801,6801,9122,7004,8907,9603,674.374,15.056,405.346,,,,
|
||||||
|
Bogota 1975 (Bogota),4802,6802,9122,7022,8904,9603,307,304,-318,,,,
|
||||||
|
Lisbon (Lisbon),4803,6803,9122,7022,8902,9603,-304.046,-60.576,103.64,,,,
|
||||||
|
Makassar (Jakarta),4804,6804,9122,7004,8908,9603,-587.8,519.75,145.76,,,,
|
||||||
|
MGI (Ferro),4805,6805,9122,7004,8909,9603,682,-203,480,,,,
|
||||||
|
Rome 1940,4806,6806,9122,7022,8906,9603,-225,-65,9,,,,
|
||||||
|
NTF (Paris),4807,6807,9105,7011,8903,9603,-168,-60,320,,,,
|
||||||
|
Tananarive (Paris),4810,6810,9105,7022,8903,9603,-189,-242,-91,,,,
|
||||||
|
Voirol 1875 (Paris),4811,6811,9105,7011,8903,9603,-73,-247,227,,,,
|
||||||
|
Batavia (Jakarta),4813,6813,9122,7004,8908,9603,-377,681,-50,,,,
|
||||||
|
Carthage (Paris),4816,6816,9105,7011,8903,9603,-263,6,431,,,,
|
||||||
|
Norsk,4817,6817,9122,7005,8913,9603,278,93,474,,,,
|
||||||
|
S-JTSK (Ferro),4818,6818,9122,7004,8909,9603,589,76,480,,,,
|
||||||
|
Nord Sahara 1959 (Paris),4819,6819,9105,7012,8903,9606,-209.3622,-87.8162,404.6198,0.0046,3.4784,0.5805,-1.4547
|
||||||
|
Segara (Jakarta),4820,6820,9122,7004,8908,9603,-403,684,41,,,,
|
||||||
|
Lisbon 1890 (Lisbon),4904,6904,9122,7004,8902,9603,508.088,-191.042,565.223,,,,
|
||||||
|
PTRA08,5013,1041,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
S-JTSK/05,5228,1052,9122,7004,8901,9607,572.213,85.334,461.94,-4.9732,-1.529,-5.2484,3.5378
|
||||||
|
S-JTSK/05 (Ferro),5229,1055,9122,7004,8909,9607,572.213,85.334,461.94,-4.9732,-1.529,-5.2484,3.5378
|
||||||
|
SLD99,5233,1053,9122,7015,8901,9607,-0.293,766.95,87.713,-0.195704,-1.695068,-3.473016,-0.039338
|
||||||
|
GDBD2009,5246,1056,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
TUREF,5252,1057,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
DRUKREF 03,5264,1058,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
ISN2004,5324,1060,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
POSGAR 2007,5340,1062,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
MARGEN,5354,1063,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
SIRGAS-Chile,5360,1064,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
CR05,5365,1065,9122,7030,8901,9603,0,0,0,,,,
|
||||||
|
MACARIO SOLIS,5371,1066,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Peru96,5373,1067,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
SIRGAS-ROU98,5381,1068,9122,7030,8901,9603,0,0,0,,,,
|
||||||
|
SIRGAS_ES2007.8,5393,1069,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Ocotepeque 1935,5451,1070,9122,7008,8901,9603,205,96,-98,,,,
|
||||||
|
RGAF09,5489,1073,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
SAD69(96),5527,1075,9122,7050,8901,9603,-67.35,3.88,-38.22,,,,
|
||||||
|
PNG94,5546,1076,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
UCS-2000,5561,1077,9122,7024,8901,9607,25,-141,-78.5,0,-0.35,-0.736,0
|
||||||
|
FEH2010,5593,1078,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
CIGD11,6135,1100,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Nepal 1981,6207,1111,9122,7015,8901,9603,293.17,726.18,245.36,,,,
|
||||||
|
CGRS93,6311,1112,9122,7030,8901,9607,8.846,-4.394,-1.122,0.00237,0.146528,-0.130428,0.783926
|
||||||
|
Mexico ITRF2008,6365,1120,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
RDN2008,6706,1132,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
Aden 1925,6881,1135,9122,7012,8901,9603,-24,-203,268,,,,
|
||||||
|
Bekaa Valley 1920,6882,1137,9122,7012,8901,9603,-183,-15,273,,,,
|
||||||
|
Bioko,6883,1136,9122,7022,8901,9603,-235,-110,393,,,,
|
||||||
|
South East Island 1943,6892,1138,9122,7012,8901,9603,-43.685,-179.785,-267.721,,,,
|
||||||
|
Gambia,6894,1139,9122,7012,8901,9603,-63,176,185,,,,
|
||||||
|
ONGD14,7373,1147,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
St. Helena Tritan,7881,1173,9122,7030,8901,9603,-0.077,0.079,0.086,,,,
|
||||||
|
SHGD2015,7886,1174,9122,7019,8901,9603,0,0,0,,,,
|
||||||
|
DOS 1968,,,9122,7022,8901,9603,230,-199,-752,,,,
|
||||||
|
European 1950 (Mean France),,,9122,7022,8901,9603,-87,-96,-120,,,,
|
||||||
|
European 1950 (Spain and Portugal),,,9122,7022,8901,9603,-84,-107,-120,,,,
|
||||||
|
Luzon Mindanao,,,9122,7008,8901,9603,-133,-79,-72,,,,
|
||||||
|
NAD27 Alaska,,,9122,7008,8901,9603,-5,135,172,,,,
|
||||||
|
NAD27 Bahamas,,,9122,7008,8901,9603,-4,154,178,,,,
|
||||||
|
NAD27 Canada,,,9122,7008,8901,9603,-10,158,187,,,,
|
||||||
|
NAD27 Canal Zone,,,9122,7008,8901,9603,0,125,201,,,,
|
||||||
|
NAD27 Caribbean,,,9122,7008,8901,9603,-3,142,183,,,,
|
||||||
|
NAD27 Central,,,9122,7008,8901,9603,0,125,194,,,,
|
||||||
|
NAD27 Cuba,,,9122,7008,8901,9603,-9,152,178,,,,
|
||||||
|
NAD27 Greenland,,,9122,7008,8901,9603,11,114,195,,,,
|
||||||
|
NAD27 Mexico,,,9122,7008,8901,9603,-12,130,190,,,,
|
||||||
|
NAD27 San Salvador,,,9122,7008,8901,9603,1,140,165,,,,
|
||||||
|
Nahrwn Masirah Ilnd,,,9122,7012,8901,9603,-247,-148,369,,,,
|
||||||
|
Nahrwn Saudi Arbia,,,9122,7012,8901,9603,-231,-196,482,,,,
|
||||||
|
Pulkovo 1942 (2),,,9122,7024,8901,9603,28,-130,-95,,,,
|
||||||
|
|
1894
pkg/csv/pcs.csv
1894
pkg/csv/pcs.csv
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
|||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "5.10"
|
!define VERSION "5.15"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}.exe"
|
OutFile "GPXSee-${VERSION}.exe"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "5.10"
|
!define VERSION "5.15"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||||
|
@ -11,23 +11,28 @@
|
|||||||
#define XTICKS 15
|
#define XTICKS 15
|
||||||
#define YTICKS 10
|
#define YTICKS 10
|
||||||
|
|
||||||
struct Label {
|
class Ticks
|
||||||
double min;
|
{
|
||||||
double max;
|
public:
|
||||||
double d;
|
Ticks(double minValue, double maxValue, int maxCount);
|
||||||
|
|
||||||
|
int count() const {return ((int)((_max - _min) / _d)) + 1;}
|
||||||
|
double val(int i) const {return _min + i * _d;}
|
||||||
|
double min() const {return _min;}
|
||||||
|
double max() const {return _max;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
double _min;
|
||||||
|
double _max;
|
||||||
|
double _d;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct Label label(double min, double max, int ticks)
|
Ticks::Ticks(double minValue, double maxValue, int maxCount)
|
||||||
{
|
{
|
||||||
double range;
|
double range = niceNum(maxValue - minValue, 0);
|
||||||
struct Label l;
|
_d = niceNum(range / maxCount, 1);
|
||||||
|
_min = ceil(minValue / _d) * _d;
|
||||||
range = niceNum(max - min, 0);
|
_max = floor(maxValue / _d) * _d;
|
||||||
l.d = niceNum(range / ticks, 1);
|
|
||||||
l.min = ceil(min / l.d) * l.d;
|
|
||||||
l.max = floor(max / l.d) * l.d;
|
|
||||||
|
|
||||||
return l;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -36,6 +41,9 @@ AxisItem::AxisItem(Type type, QGraphicsItem *parent) : QGraphicsItem(parent)
|
|||||||
_type = type;
|
_type = type;
|
||||||
_size = 0;
|
_size = 0;
|
||||||
|
|
||||||
|
_font.setPixelSize(FONT_SIZE);
|
||||||
|
_font.setFamily(FONT_FAMILY);
|
||||||
|
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
@ -45,6 +53,16 @@ void AxisItem::setRange(const RangeF &range)
|
|||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_range = range;
|
_range = range;
|
||||||
|
|
||||||
|
QFontMetrics fm(_font);
|
||||||
|
Ticks ticks(_range.min(), _range.max(), (_type == X) ? XTICKS : YTICKS);
|
||||||
|
_ticks = QVector<Tick>(ticks.count());
|
||||||
|
for (int i = 0; i < ticks.count(); i++) {
|
||||||
|
Tick &t = _ticks[i];
|
||||||
|
t.value = ticks.val(i);
|
||||||
|
t.boundingBox = fm.tightBoundingRect(QString::number(t.value));
|
||||||
|
}
|
||||||
|
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -60,42 +78,28 @@ void AxisItem::setSize(qreal size)
|
|||||||
void AxisItem::setLabel(const QString& label)
|
void AxisItem::setLabel(const QString& label)
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
QFontMetrics fm(_font);
|
||||||
_label = label;
|
_label = label;
|
||||||
|
_labelBB = fm.tightBoundingRect(label);
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxisItem::updateBoundingRect()
|
void AxisItem::updateBoundingRect()
|
||||||
{
|
{
|
||||||
QFont font;
|
QFontMetrics fm(_font);
|
||||||
font.setPixelSize(FONT_SIZE);
|
QRect es = _ticks.isEmpty() ? QRect() : _ticks.last().boundingBox;
|
||||||
font.setFamily(FONT_FAMILY);
|
QRect ss = _ticks.isEmpty() ? QRect() : _ticks.first().boundingBox;
|
||||||
QFontMetrics fm(font);
|
QRect ls(_labelBB);
|
||||||
QRect ss, es, ls;
|
|
||||||
struct Label l;
|
|
||||||
|
|
||||||
|
|
||||||
l = label(_range.min(), _range.max(), (_type == X) ? XTICKS : YTICKS);
|
|
||||||
es = fm.tightBoundingRect(QString::number(l.max));
|
|
||||||
ss = fm.tightBoundingRect(QString::number(l.min));
|
|
||||||
ls = fm.tightBoundingRect(_label);
|
|
||||||
|
|
||||||
if (_type == X) {
|
if (_type == X) {
|
||||||
_boundingRect = QRectF(-ss.width()/2, -TICK/2,
|
_boundingRect = QRectF(-ss.width()/2, -TICK/2, _size + es.width()/2
|
||||||
_size + es.width()/2 + ss.width()/2,
|
+ ss.width()/2, ls.height() + es.height() - fm.descent() + TICK
|
||||||
ls.height() + es.height() - fm.descent() + TICK + 2*PADDING + 1);
|
+ 2*PADDING + 1);
|
||||||
} else {
|
} else {
|
||||||
int mtw = 0;
|
int mtw = 0;
|
||||||
QRect ts;
|
for (int i = 0; i < _ticks.count(); i++)
|
||||||
qreal val;
|
mtw = qMax(_ticks.at(i).boundingBox.width(), mtw);
|
||||||
|
|
||||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
|
||||||
val = l.min + i * l.d;
|
|
||||||
QString str = QString::number(val);
|
|
||||||
ts = fm.tightBoundingRect(str);
|
|
||||||
mtw = qMax(ts.width(), mtw);
|
|
||||||
}
|
|
||||||
|
|
||||||
_boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING + TICK/2),
|
_boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING + TICK/2),
|
||||||
-(_size + es.height()/2 + fm.descent()), ls.height() + mtw + 2*PADDING
|
-(_size + es.height()/2 + fm.descent()), ls.height() + mtw + 2*PADDING
|
||||||
+ TICK, _size + es.height()/2 + fm.descent() + ss.height()/2);
|
+ TICK, _size + es.height()/2 + fm.descent() + ss.height()/2);
|
||||||
@ -107,60 +111,50 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
QFont font;
|
QFontMetrics fm(_font);
|
||||||
font.setPixelSize(FONT_SIZE);
|
QRect ts;
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRect ts, ls;
|
|
||||||
struct Label l;
|
|
||||||
qreal range = _range.size();
|
|
||||||
qreal val;
|
|
||||||
QPen pen = QPen(Qt::black, AXIS_WIDTH);
|
|
||||||
|
|
||||||
|
|
||||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
painter->setFont(font);
|
painter->setFont(_font);
|
||||||
painter->setPen(pen);
|
painter->setPen(QPen(Qt::black, AXIS_WIDTH));
|
||||||
|
|
||||||
ls = fm.tightBoundingRect(_label);
|
|
||||||
|
|
||||||
if (_type == X) {
|
if (_type == X) {
|
||||||
painter->drawLine(0, 0, _size, 0);
|
painter->drawLine(0, 0, _size, 0);
|
||||||
|
|
||||||
l = label(_range.min(), _range.max(), XTICKS);
|
for (int i = 0; i < _ticks.count(); i++) {
|
||||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
qreal val = _ticks.at(i).value;
|
||||||
val = l.min + i * l.d;
|
ts = _ticks.at(i).boundingBox;
|
||||||
QString str = QString::number(val);
|
|
||||||
|
|
||||||
painter->drawLine((_size/range) * (val - _range.min()), TICK/2,
|
painter->drawLine((_size/_range.size()) * (val - _range.min()),
|
||||||
(_size/range) * (val - _range.min()), -TICK/2);
|
TICK/2, (_size/_range.size()) * (val - _range.min()), -TICK/2);
|
||||||
ts = fm.tightBoundingRect(str);
|
painter->drawText(((_size/_range.size()) * (val - _range.min()))
|
||||||
painter->drawText(((_size/range) * (val - _range.min()))
|
- (ts.width()/2), ts.height() + TICK/2 + PADDING,
|
||||||
- (ts.width()/2), ts.height() + TICK/2 + PADDING, str);
|
QString::number(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->drawText(_size/2 - ls.width()/2, ls.height() + ts.height()
|
painter->drawText(_size/2 - _labelBB.width()/2, _labelBB.height()
|
||||||
- 2*fm.descent() + TICK/2 + 2*PADDING, _label);
|
+ ts.height() - 2*fm.descent() + TICK/2 + 2*PADDING, _label);
|
||||||
} else {
|
} else {
|
||||||
painter->drawLine(0, 0, 0, -_size);
|
painter->drawLine(0, 0, 0, -_size);
|
||||||
|
|
||||||
l = label(_range.min(), _range.max(), YTICKS);
|
|
||||||
int mtw = 0;
|
int mtw = 0;
|
||||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
for (int i = 0; i < _ticks.count(); i++) {
|
||||||
val = l.min + i * l.d;
|
qreal val = _ticks.at(i).value;
|
||||||
QString str = QString::number(val);
|
ts = _ticks.at(i).boundingBox;
|
||||||
|
|
||||||
painter->drawLine(TICK/2, -((_size/range) * (val - _range.min())),
|
|
||||||
-TICK/2, -((_size/range) * (val - _range.min())));
|
|
||||||
ts = fm.tightBoundingRect(str);
|
|
||||||
mtw = qMax(ts.width(), mtw);
|
mtw = qMax(ts.width(), mtw);
|
||||||
painter->drawText(-(ts.width() + PADDING + TICK/2), -((_size/range)
|
|
||||||
* (val - _range.min())) + (ts.height()/2), str);
|
painter->drawLine(TICK/2, -((_size/_range.size())
|
||||||
|
* (val - _range.min())), -TICK/2, -((_size/_range.size())
|
||||||
|
* (val - _range.min())));
|
||||||
|
painter->drawText(-(ts.width() + PADDING + TICK/2),
|
||||||
|
-((_size/_range.size()) * (val - _range.min())) + (ts.height()/2),
|
||||||
|
QString::number(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->rotate(-90);
|
painter->rotate(-90);
|
||||||
painter->drawText(_size/2 - ls.width()/2, -(mtw + 2*PADDING + TICK/2),
|
painter->drawText(_size/2 - _labelBB.width()/2, -(mtw + 2*PADDING
|
||||||
_label);
|
+ TICK/2), _label);
|
||||||
painter->rotate(90);
|
painter->rotate(90);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,46 +166,28 @@ void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
|
|
||||||
QSizeF AxisItem::margin() const
|
QSizeF AxisItem::margin() const
|
||||||
{
|
{
|
||||||
QFont font;
|
QFontMetrics fm(_font);
|
||||||
font.setPixelSize(FONT_SIZE);
|
QRect es = _ticks.isEmpty() ? QRect() : _ticks.last().boundingBox;
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRect ss, es, ls;
|
|
||||||
struct Label l;
|
|
||||||
|
|
||||||
|
|
||||||
l = label(_range.min(), _range.max(), (_type == X) ? XTICKS : YTICKS);
|
|
||||||
es = fm.tightBoundingRect(QString::number(l.max));
|
|
||||||
ss = fm.tightBoundingRect(QString::number(l.min));
|
|
||||||
ls = fm.tightBoundingRect(_label);
|
|
||||||
|
|
||||||
if (_type == X) {
|
if (_type == X) {
|
||||||
return QSizeF(es.width()/2,
|
return QSizeF(es.width()/2, _labelBB.height() + es.height()
|
||||||
ls.height() + es.height() - fm.descent() + TICK/2 + 2*PADDING);
|
- fm.descent() + TICK/2 + 2*PADDING);
|
||||||
} else {
|
} else {
|
||||||
int mtw = 0;
|
int mtw = 0;
|
||||||
QRect ts;
|
for (int i = 0; i < _ticks.count(); i++)
|
||||||
qreal val;
|
mtw = qMax(_ticks.at(i).boundingBox.width(), mtw);
|
||||||
|
|
||||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++) {
|
return QSizeF(_labelBB.height() -fm.descent() + mtw + 2*PADDING
|
||||||
val = l.min + i * l.d;
|
|
||||||
QString str = QString::number(val);
|
|
||||||
ts = fm.tightBoundingRect(str);
|
|
||||||
mtw = qMax(ts.width(), mtw);
|
|
||||||
}
|
|
||||||
|
|
||||||
return QSizeF(ls.height() -fm.descent() + mtw + 2*PADDING
|
|
||||||
+ TICK/2, es.height()/2 + fm.descent());
|
+ TICK/2, es.height()/2 + fm.descent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<qreal> AxisItem::ticks() const
|
QList<qreal> AxisItem::ticks() const
|
||||||
{
|
{
|
||||||
struct Label l;
|
|
||||||
QList<qreal> list;
|
QList<qreal> list;
|
||||||
|
|
||||||
l = label(_range.min(), _range.max(), (_type == X) ? XTICKS : YTICKS);
|
for (int i = 0; i < _ticks.count(); i++)
|
||||||
for (int i = 0; i < ((l.max - l.min) / l.d) + 1; i++)
|
list.append(((_size/_range.size()) * (_ticks.at(i).value
|
||||||
list.append(((_size/_range.size()) * ((l.min + i * l.d)
|
|
||||||
- _range.min())));
|
- _range.min())));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define AXISITEM_H
|
#define AXISITEM_H
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
#include <QVector>
|
||||||
#include "common/range.h"
|
#include "common/range.h"
|
||||||
|
|
||||||
class AxisItem : public QGraphicsItem
|
class AxisItem : public QGraphicsItem
|
||||||
@ -23,13 +24,21 @@ public:
|
|||||||
QList<qreal> ticks() const;
|
QList<qreal> ticks() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct Tick {
|
||||||
|
double value;
|
||||||
|
QRect boundingBox;
|
||||||
|
};
|
||||||
|
|
||||||
void updateBoundingRect();
|
void updateBoundingRect();
|
||||||
|
|
||||||
Type _type;
|
Type _type;
|
||||||
RangeF _range;
|
RangeF _range;
|
||||||
qreal _size;
|
qreal _size;
|
||||||
QString _label;
|
QString _label;
|
||||||
|
QRect _labelBB;
|
||||||
|
QVector<Tick> _ticks;
|
||||||
QRectF _boundingRect;
|
QRectF _boundingRect;
|
||||||
|
QFont _font;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AXISITEM_H
|
#endif // AXISITEM_H
|
||||||
|
@ -13,11 +13,6 @@ FileBrowser::FileBrowser(QObject *parent) : QObject(parent)
|
|||||||
_index = -1;
|
_index = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileBrowser::~FileBrowser()
|
|
||||||
{
|
|
||||||
delete _watcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileBrowser::setCurrent(const QString &path)
|
void FileBrowser::setCurrent(const QString &path)
|
||||||
{
|
{
|
||||||
QFileInfo file(path);
|
QFileInfo file(path);
|
||||||
|
@ -13,7 +13,6 @@ class FileBrowser : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
FileBrowser(QObject *parent = 0);
|
FileBrowser(QObject *parent = 0);
|
||||||
~FileBrowser();
|
|
||||||
|
|
||||||
void setFilter(const QStringList &filter);
|
void setFilter(const QStringList &filter);
|
||||||
void setCurrent(const QString &path);
|
void setCurrent(const QString &path);
|
||||||
|
94
src/GUI/gearratiograph.cpp
Normal file
94
src/GUI/gearratiograph.cpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
#include "data/data.h"
|
||||||
|
#include "gearratiographitem.h"
|
||||||
|
#include "gearratiograph.h"
|
||||||
|
|
||||||
|
|
||||||
|
GearRatioGraph::GearRatioGraph(QWidget *parent) : GraphTab(parent)
|
||||||
|
{
|
||||||
|
_showTracks = true;
|
||||||
|
|
||||||
|
GraphView::setYUnits("");
|
||||||
|
setYLabel(tr("Gear ratio"));
|
||||||
|
|
||||||
|
setSliderPrecision(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GearRatioGraph::setInfo()
|
||||||
|
{
|
||||||
|
if (_showTracks) {
|
||||||
|
GraphView::addInfo(tr("Most used"), QString::number(top() * yScale(),
|
||||||
|
'f', 2) + UNIT_SPACE + yUnits());
|
||||||
|
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale(), 'f',
|
||||||
|
2) + UNIT_SPACE + yUnits());
|
||||||
|
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
|
||||||
|
2) + UNIT_SPACE + yUnits());
|
||||||
|
} else
|
||||||
|
clearInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<GraphItem*> GearRatioGraph::loadData(const Data &data)
|
||||||
|
{
|
||||||
|
QList<GraphItem*> graphs;
|
||||||
|
|
||||||
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
|
const Graph &graph = data.tracks().at(i)->ratio();
|
||||||
|
|
||||||
|
if (graph.size() < 2) {
|
||||||
|
skipColor();
|
||||||
|
graphs.append(0);
|
||||||
|
} else {
|
||||||
|
GearRatioGraphItem *gi = new GearRatioGraphItem(graph, _graphType);
|
||||||
|
GraphView::addGraph(gi);
|
||||||
|
|
||||||
|
for (QMap<qreal, qreal>::const_iterator it = gi->map().constBegin();
|
||||||
|
it != gi->map().constEnd(); ++it)
|
||||||
|
_map.insert(it.key(), _map.value(it.key()) + it.value());
|
||||||
|
graphs.append(gi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < data.routes().count(); i++) {
|
||||||
|
skipColor();
|
||||||
|
graphs.append(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
setInfo();
|
||||||
|
redraw();
|
||||||
|
|
||||||
|
return graphs;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal GearRatioGraph::top() const
|
||||||
|
{
|
||||||
|
qreal key = NAN, val = NAN;
|
||||||
|
|
||||||
|
for (QMap<qreal, qreal>::const_iterator it = _map.constBegin();
|
||||||
|
it != _map.constEnd(); ++it) {
|
||||||
|
if (it == _map.constBegin()) {
|
||||||
|
val = it.value();
|
||||||
|
key = it.key();
|
||||||
|
} else if (it.value() > val) {
|
||||||
|
val = it.value();
|
||||||
|
key = it.key();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GearRatioGraph::clear()
|
||||||
|
{
|
||||||
|
_map.clear();
|
||||||
|
|
||||||
|
GraphView::clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GearRatioGraph::showTracks(bool show)
|
||||||
|
{
|
||||||
|
_showTracks = show;
|
||||||
|
|
||||||
|
showGraph(show);
|
||||||
|
setInfo();
|
||||||
|
|
||||||
|
redraw();
|
||||||
|
}
|
30
src/GUI/gearratiograph.h
Normal file
30
src/GUI/gearratiograph.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef GEARRATIOGRAPH_H
|
||||||
|
#define GEARRATIOGRAPH_H
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include "graphtab.h"
|
||||||
|
|
||||||
|
class GearRatioGraph : public GraphTab
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GearRatioGraph(QWidget *parent = 0);
|
||||||
|
|
||||||
|
QString label() const {return tr("Gear ratio");}
|
||||||
|
QList<GraphItem*> loadData(const Data &data);
|
||||||
|
void clear();
|
||||||
|
void showTracks(bool show);
|
||||||
|
|
||||||
|
private:
|
||||||
|
qreal top() const;
|
||||||
|
qreal min() const {return bounds().top();}
|
||||||
|
qreal max() const {return bounds().bottom();}
|
||||||
|
void setInfo();
|
||||||
|
|
||||||
|
QMap<qreal, qreal> _map;
|
||||||
|
|
||||||
|
bool _showTracks;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GEARRATIOGRAPH_H
|
39
src/GUI/gearratiographitem.cpp
Normal file
39
src/GUI/gearratiographitem.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include <QMap>
|
||||||
|
#include "tooltip.h"
|
||||||
|
#include "gearratiographitem.h"
|
||||||
|
|
||||||
|
GearRatioGraphItem::GearRatioGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
|
{
|
||||||
|
qreal val = NAN;
|
||||||
|
|
||||||
|
for (int j = 1; j < graph.size(); j++) {
|
||||||
|
const GraphPoint &p = graph.at(j);
|
||||||
|
qreal val = _map.value(p.y());
|
||||||
|
_map.insert(p.y(), val + (p.s() - graph.at(j-1).s()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (QMap<qreal, qreal>::const_iterator it = _map.constBegin();
|
||||||
|
it != _map.constEnd(); ++it) {
|
||||||
|
if (it == _map.constBegin()) {
|
||||||
|
val = it.value();
|
||||||
|
_top = it.key();
|
||||||
|
} else if (it.value() > val) {
|
||||||
|
val = it.value();
|
||||||
|
_top = it.key();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setToolTip(toolTip());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GearRatioGraphItem::toolTip() const
|
||||||
|
{
|
||||||
|
ToolTip tt;
|
||||||
|
|
||||||
|
tt.insert(tr("Minimum"), QString::number(min(), 'f', 2));
|
||||||
|
tt.insert(tr("Maximum"), QString::number(max(), 'f', 2));
|
||||||
|
tt.insert(tr("Most used"), QString::number(top(), 'f', 2));
|
||||||
|
|
||||||
|
return tt.toString();
|
||||||
|
}
|
28
src/GUI/gearratiographitem.h
Normal file
28
src/GUI/gearratiographitem.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#ifndef GEARRATIOGRAPHITEM_H
|
||||||
|
#define GEARRATIOGRAPHITEM_H
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include "graphitem.h"
|
||||||
|
|
||||||
|
class GearRatioGraphItem : public GraphItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GearRatioGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
|
qreal min() const {return -bounds().bottom();}
|
||||||
|
qreal max() const {return -bounds().top();}
|
||||||
|
qreal top() const {return _top;}
|
||||||
|
|
||||||
|
const QMap<qreal, qreal> &map() const {return _map;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString toolTip() const;
|
||||||
|
|
||||||
|
QMap<qreal, qreal> _map;
|
||||||
|
qreal _top;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GEARRATIOGRAPHITEM_H
|
@ -3,6 +3,8 @@
|
|||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPaintEngine>
|
#include <QPaintEngine>
|
||||||
#include <QPaintDevice>
|
#include <QPaintDevice>
|
||||||
|
#include <QGraphicsSimpleTextItem>
|
||||||
|
#include <QPalette>
|
||||||
#include "data/graph.h"
|
#include "data/graph.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -41,6 +43,9 @@ GraphView::GraphView(QWidget *parent)
|
|||||||
_sliderInfo->setZValue(3.0);
|
_sliderInfo->setZValue(3.0);
|
||||||
_info = new InfoItem();
|
_info = new InfoItem();
|
||||||
_grid = new GridItem();
|
_grid = new GridItem();
|
||||||
|
_message = new QGraphicsSimpleTextItem(tr("Data not available"));
|
||||||
|
_message->setBrush(QPalette().brush(QPalette::Disabled,
|
||||||
|
QPalette::WindowText));
|
||||||
|
|
||||||
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
||||||
SLOT(emitSliderPositionChanged(const QPointF&)));
|
SLOT(emitSliderPositionChanged(const QPointF&)));
|
||||||
@ -63,30 +68,27 @@ GraphView::GraphView(QWidget *parent)
|
|||||||
|
|
||||||
GraphView::~GraphView()
|
GraphView::~GraphView()
|
||||||
{
|
{
|
||||||
if (_xAxis->scene() != _scene)
|
delete _xAxis;
|
||||||
delete _xAxis;
|
delete _yAxis;
|
||||||
if (_yAxis->scene() != _scene)
|
delete _slider;
|
||||||
delete _yAxis;
|
delete _info;
|
||||||
if (_slider->scene() != _scene)
|
delete _grid;
|
||||||
delete _slider;
|
delete _message;
|
||||||
if (_info->scene() != _scene)
|
|
||||||
delete _info;
|
|
||||||
if (_grid->scene() != _scene)
|
|
||||||
delete _grid;
|
|
||||||
|
|
||||||
for (int i = 0; i < _graphs.count(); i++)
|
for (int i = 0; i < _graphs.count(); i++)
|
||||||
if (_graphs.at(i)->scene() != _scene)
|
delete _graphs[i];
|
||||||
delete _graphs[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::createXLabel()
|
void GraphView::createXLabel()
|
||||||
{
|
{
|
||||||
_xAxis->setLabel(QString("%1 [%2]").arg(_xLabel, _xUnits));
|
_xAxis->setLabel(QString("%1 [%2]").arg(_xLabel,
|
||||||
|
_xUnits.isEmpty() ? "-" : _xUnits));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::createYLabel()
|
void GraphView::createYLabel()
|
||||||
{
|
{
|
||||||
_yAxis->setLabel(QString("%1 [%2]").arg(_yLabel, _yUnits));
|
_yAxis->setLabel(QString("%1 [%2]").arg(_yLabel,
|
||||||
|
_yUnits.isEmpty() ? "-" : _yUnits));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::setYLabel(const QString &label)
|
void GraphView::setYLabel(const QString &label)
|
||||||
@ -163,9 +165,16 @@ void GraphView::setGraphType(GraphType type)
|
|||||||
_bounds = QRectF();
|
_bounds = QRectF();
|
||||||
|
|
||||||
for (int i = 0; i < _graphs.count(); i++) {
|
for (int i = 0; i < _graphs.count(); i++) {
|
||||||
_graphs.at(i)->setGraphType(type);
|
GraphItem *gi = _graphs.at(i);
|
||||||
if (_graphs.at(i)->scene() == _scene)
|
gi->setGraphType(type);
|
||||||
_bounds |= _graphs.at(i)->bounds();
|
if (!_hide.contains(gi->id())) {
|
||||||
|
if (gi->bounds().width() > 0)
|
||||||
|
addItem(gi);
|
||||||
|
else
|
||||||
|
removeItem(gi);
|
||||||
|
}
|
||||||
|
if (gi->scene() == _scene)
|
||||||
|
_bounds |= gi->bounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == Distance)
|
if (type == Distance)
|
||||||
@ -204,8 +213,10 @@ void GraphView::addGraph(GraphItem *graph, int id)
|
|||||||
|
|
||||||
if (!_hide.contains(id)) {
|
if (!_hide.contains(id)) {
|
||||||
_visible.append(graph);
|
_visible.append(graph);
|
||||||
_scene->addItem(graph);
|
if (graph->bounds().width() > 0) {
|
||||||
_bounds |= graph->bounds();
|
_scene->addItem(graph);
|
||||||
|
_bounds |= graph->bounds();
|
||||||
|
}
|
||||||
setXUnits();
|
setXUnits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,13 +243,15 @@ void GraphView::showGraph(bool show, int id)
|
|||||||
_visible.clear();
|
_visible.clear();
|
||||||
_bounds = QRectF();
|
_bounds = QRectF();
|
||||||
for (int i = 0; i < _graphs.count(); i++) {
|
for (int i = 0; i < _graphs.count(); i++) {
|
||||||
GraphItem* gi = _graphs.at(i);
|
GraphItem *gi = _graphs.at(i);
|
||||||
if (_hide.contains(gi->id()))
|
if (_hide.contains(gi->id()))
|
||||||
removeItem(gi);
|
removeItem(gi);
|
||||||
else {
|
else {
|
||||||
addItem(gi);
|
|
||||||
_visible.append(gi);
|
_visible.append(gi);
|
||||||
_bounds |= gi->bounds();
|
if (gi->bounds().width() > 0) {
|
||||||
|
addItem(gi);
|
||||||
|
_bounds |= gi->bounds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,7 +265,8 @@ QRectF GraphView::bounds() const
|
|||||||
|
|
||||||
void GraphView::redraw()
|
void GraphView::redraw()
|
||||||
{
|
{
|
||||||
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
if (!_graphs.isEmpty())
|
||||||
|
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::redraw(const QSizeF &size)
|
void GraphView::redraw(const QSizeF &size)
|
||||||
@ -263,16 +277,18 @@ void GraphView::redraw(const QSizeF &size)
|
|||||||
qreal sx, sy;
|
qreal sx, sy;
|
||||||
|
|
||||||
|
|
||||||
if (_visible.isEmpty() || _bounds.isNull()) {
|
if (_bounds.isNull()) {
|
||||||
removeItem(_xAxis);
|
removeItem(_xAxis);
|
||||||
removeItem(_yAxis);
|
removeItem(_yAxis);
|
||||||
removeItem(_slider);
|
removeItem(_slider);
|
||||||
removeItem(_info);
|
removeItem(_info);
|
||||||
removeItem(_grid);
|
removeItem(_grid);
|
||||||
_scene->setSceneRect(QRectF());
|
addItem(_message);
|
||||||
|
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeItem(_message);
|
||||||
addItem(_xAxis);
|
addItem(_xAxis);
|
||||||
addItem(_yAxis);
|
addItem(_yAxis);
|
||||||
addItem(_slider);
|
addItem(_slider);
|
||||||
@ -308,6 +324,7 @@ void GraphView::redraw(const QSizeF &size)
|
|||||||
if (r.height() < _minYRange * sy)
|
if (r.height() < _minYRange * sy)
|
||||||
r.adjust(0, -(_minYRange/2 * sy - r.height()/2), 0,
|
r.adjust(0, -(_minYRange/2 * sy - r.height()/2), 0,
|
||||||
(_minYRange/2) * sy - r.height()/2);
|
(_minYRange/2) * sy - r.height()/2);
|
||||||
|
r = r.toRect();
|
||||||
|
|
||||||
_xAxis->setSize(r.width());
|
_xAxis->setSize(r.width());
|
||||||
_yAxis->setSize(r.height());
|
_yAxis->setSize(r.height());
|
||||||
@ -329,9 +346,11 @@ void GraphView::redraw(const QSizeF &size)
|
|||||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::resizeEvent(QResizeEvent *)
|
void GraphView::resizeEvent(QResizeEvent *e)
|
||||||
{
|
{
|
||||||
redraw();
|
redraw(e->size() - QSizeF(MARGIN, MARGIN));
|
||||||
|
|
||||||
|
QGraphicsView::resizeEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::mousePressEvent(QMouseEvent *e)
|
void GraphView::mousePressEvent(QMouseEvent *e)
|
||||||
|
@ -16,6 +16,7 @@ class InfoItem;
|
|||||||
class GraphItem;
|
class GraphItem;
|
||||||
class PathItem;
|
class PathItem;
|
||||||
class GridItem;
|
class GridItem;
|
||||||
|
class QGraphicsSimpleTextItem;
|
||||||
|
|
||||||
class GraphView : public QGraphicsView
|
class GraphView : public QGraphicsView
|
||||||
{
|
{
|
||||||
@ -64,7 +65,6 @@ protected:
|
|||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds() const;
|
||||||
void redraw();
|
void redraw();
|
||||||
void redraw(const QSizeF &size);
|
|
||||||
void addInfo(const QString &key, const QString &value);
|
void addInfo(const QString &key, const QString &value);
|
||||||
void clearInfo();
|
void clearInfo();
|
||||||
void skipColor() {_palette.nextColor();}
|
void skipColor() {_palette.nextColor();}
|
||||||
@ -77,6 +77,7 @@ private slots:
|
|||||||
void newSliderPosition(const QPointF &pos);
|
void newSliderPosition(const QPointF &pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void redraw(const QSizeF &size);
|
||||||
void setXUnits();
|
void setXUnits();
|
||||||
void createXLabel();
|
void createXLabel();
|
||||||
void createYLabel();
|
void createYLabel();
|
||||||
@ -85,8 +86,8 @@ private:
|
|||||||
void removeItem(QGraphicsItem *item);
|
void removeItem(QGraphicsItem *item);
|
||||||
void addItem(QGraphicsItem *item);
|
void addItem(QGraphicsItem *item);
|
||||||
|
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *e);
|
||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *e);
|
||||||
|
|
||||||
Units _units;
|
Units _units;
|
||||||
qreal _xScale, _yScale;
|
qreal _xScale, _yScale;
|
||||||
@ -104,6 +105,7 @@ private:
|
|||||||
SliderInfoItem *_sliderInfo;
|
SliderInfoItem *_sliderInfo;
|
||||||
InfoItem *_info;
|
InfoItem *_info;
|
||||||
GridItem *_grid;
|
GridItem *_grid;
|
||||||
|
QGraphicsSimpleTextItem *_message;
|
||||||
|
|
||||||
QList<GraphItem*> _visible;
|
QList<GraphItem*> _visible;
|
||||||
QSet<int> _hide;
|
QSet<int> _hide;
|
||||||
|
@ -4,13 +4,6 @@
|
|||||||
|
|
||||||
#define GRID_WIDTH 0
|
#define GRID_WIDTH 0
|
||||||
|
|
||||||
GridItem::GridItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
|
||||||
{
|
|
||||||
#ifndef Q_OS_MAC
|
|
||||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
|
||||||
#endif // Q_OS_MAC
|
|
||||||
}
|
|
||||||
|
|
||||||
void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget)
|
QWidget *widget)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
class GridItem : public QGraphicsItem
|
class GridItem : public QGraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GridItem(QGraphicsItem *parent = 0);
|
GridItem(QGraphicsItem *parent = 0): QGraphicsItem(parent) {}
|
||||||
|
|
||||||
QRectF boundingRect() const {return _boundingRect;}
|
QRectF boundingRect() const {return _boundingRect;}
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include "data/data.h"
|
#include "data/data.h"
|
||||||
|
#include "data/poi.h"
|
||||||
#include "map/maplist.h"
|
#include "map/maplist.h"
|
||||||
#include "map/emptymap.h"
|
#include "map/emptymap.h"
|
||||||
#include "map/downloader.h"
|
#include "map/downloader.h"
|
||||||
@ -36,6 +37,7 @@
|
|||||||
#include "temperaturegraph.h"
|
#include "temperaturegraph.h"
|
||||||
#include "cadencegraph.h"
|
#include "cadencegraph.h"
|
||||||
#include "powergraph.h"
|
#include "powergraph.h"
|
||||||
|
#include "gearratiograph.h"
|
||||||
#include "mapview.h"
|
#include "mapview.h"
|
||||||
#include "trackinfo.h"
|
#include "trackinfo.h"
|
||||||
#include "filebrowser.h"
|
#include "filebrowser.h"
|
||||||
@ -96,14 +98,6 @@ GUI::GUI()
|
|||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::~GUI()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _tabs.size(); i++) {
|
|
||||||
if (_graphTabWidget->indexOf(_tabs.at(i)) < 0)
|
|
||||||
delete _tabs.at(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::loadMaps()
|
void GUI::loadMaps()
|
||||||
{
|
{
|
||||||
_ml = new MapList(this);
|
_ml = new MapList(this);
|
||||||
@ -557,12 +551,13 @@ void GUI::createGraphTabs()
|
|||||||
_graphTabWidget->setDocumentMode(true);
|
_graphTabWidget->setDocumentMode(true);
|
||||||
#endif // Q_OS_WIN32
|
#endif // Q_OS_WIN32
|
||||||
|
|
||||||
_tabs.append(new ElevationGraph);
|
_tabs.append(new ElevationGraph(_graphTabWidget));
|
||||||
_tabs.append(new SpeedGraph);
|
_tabs.append(new SpeedGraph(_graphTabWidget));
|
||||||
_tabs.append(new HeartRateGraph);
|
_tabs.append(new HeartRateGraph(_graphTabWidget));
|
||||||
_tabs.append(new CadenceGraph);
|
_tabs.append(new CadenceGraph(_graphTabWidget));
|
||||||
_tabs.append(new PowerGraph);
|
_tabs.append(new PowerGraph(_graphTabWidget));
|
||||||
_tabs.append(new TemperatureGraph);
|
_tabs.append(new TemperatureGraph(_graphTabWidget));
|
||||||
|
_tabs.append(new GearRatioGraph(_graphTabWidget));
|
||||||
|
|
||||||
for (int i = 0; i < _tabs.count(); i++)
|
for (int i = 0; i < _tabs.count(); i++)
|
||||||
connect(_tabs.at(i), SIGNAL(sliderPositionChanged(qreal)), this,
|
connect(_tabs.at(i), SIGNAL(sliderPositionChanged(qreal)), this,
|
||||||
@ -867,6 +862,7 @@ void GUI::openOptions()
|
|||||||
SET_TRACK_OPTION(outlierEliminate, setOutlierElimination);
|
SET_TRACK_OPTION(outlierEliminate, setOutlierElimination);
|
||||||
SET_TRACK_OPTION(pauseSpeed, setPauseSpeed);
|
SET_TRACK_OPTION(pauseSpeed, setPauseSpeed);
|
||||||
SET_TRACK_OPTION(pauseInterval, setPauseInterval);
|
SET_TRACK_OPTION(pauseInterval, setPauseInterval);
|
||||||
|
SET_TRACK_OPTION(useReportedSpeed, useReportedSpeed);
|
||||||
|
|
||||||
if (options.poiRadius != _options.poiRadius)
|
if (options.poiRadius != _options.poiRadius)
|
||||||
_poi->setRadius(options.poiRadius);
|
_poi->setRadius(options.poiRadius);
|
||||||
@ -1638,6 +1634,8 @@ void GUI::writeSettings()
|
|||||||
settings.setValue(PAUSE_SPEED_SETTING, _options.pauseSpeed);
|
settings.setValue(PAUSE_SPEED_SETTING, _options.pauseSpeed);
|
||||||
if (_options.pauseInterval != PAUSE_INTERVAL_DEFAULT)
|
if (_options.pauseInterval != PAUSE_INTERVAL_DEFAULT)
|
||||||
settings.setValue(PAUSE_INTERVAL_SETTING, _options.pauseInterval);
|
settings.setValue(PAUSE_INTERVAL_SETTING, _options.pauseInterval);
|
||||||
|
if (_options.useReportedSpeed != USE_REPORTED_SPEED_DEFAULT)
|
||||||
|
settings.setValue(USE_REPORTED_SPEED_SETTING, _options.useReportedSpeed);
|
||||||
if (_options.poiRadius != POI_RADIUS_DEFAULT)
|
if (_options.poiRadius != POI_RADIUS_DEFAULT)
|
||||||
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
|
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
|
||||||
if (_options.useOpenGL != USE_OPENGL_DEFAULT)
|
if (_options.useOpenGL != USE_OPENGL_DEFAULT)
|
||||||
@ -1866,6 +1864,8 @@ void GUI::readSettings()
|
|||||||
OUTLIER_ELIMINATE_DEFAULT).toBool();
|
OUTLIER_ELIMINATE_DEFAULT).toBool();
|
||||||
_options.pauseSpeed = settings.value(PAUSE_SPEED_SETTING,
|
_options.pauseSpeed = settings.value(PAUSE_SPEED_SETTING,
|
||||||
PAUSE_SPEED_DEFAULT).toFloat();
|
PAUSE_SPEED_DEFAULT).toFloat();
|
||||||
|
_options.useReportedSpeed = settings.value(USE_REPORTED_SPEED_SETTING,
|
||||||
|
USE_REPORTED_SPEED_DEFAULT).toBool();
|
||||||
_options.pauseInterval = settings.value(PAUSE_INTERVAL_SETTING,
|
_options.pauseInterval = settings.value(PAUSE_INTERVAL_SETTING,
|
||||||
PAUSE_INTERVAL_DEFAULT).toInt();
|
PAUSE_INTERVAL_DEFAULT).toInt();
|
||||||
_options.poiRadius = settings.value(POI_RADIUS_SETTING, POI_RADIUS_DEFAULT)
|
_options.poiRadius = settings.value(POI_RADIUS_SETTING, POI_RADIUS_DEFAULT)
|
||||||
@ -1931,6 +1931,7 @@ void GUI::readSettings()
|
|||||||
Track::setOutlierElimination(_options.outlierEliminate);
|
Track::setOutlierElimination(_options.outlierEliminate);
|
||||||
Track::setPauseSpeed(_options.pauseSpeed);
|
Track::setPauseSpeed(_options.pauseSpeed);
|
||||||
Track::setPauseInterval(_options.pauseInterval);
|
Track::setPauseInterval(_options.pauseInterval);
|
||||||
|
Track::useReportedSpeed(_options.useReportedSpeed);
|
||||||
|
|
||||||
_poi->setRadius(_options.poiRadius);
|
_poi->setRadius(_options.poiRadius);
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
#include "data/graph.h"
|
#include "data/graph.h"
|
||||||
#include "data/poi.h"
|
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "timetype.h"
|
#include "timetype.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
@ -28,6 +27,7 @@ class GraphTab;
|
|||||||
class MapView;
|
class MapView;
|
||||||
class Map;
|
class Map;
|
||||||
class MapList;
|
class MapList;
|
||||||
|
class POI;
|
||||||
|
|
||||||
class GUI : public QMainWindow
|
class GUI : public QMainWindow
|
||||||
{
|
{
|
||||||
@ -35,7 +35,6 @@ class GUI : public QMainWindow
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
GUI();
|
GUI();
|
||||||
~GUI();
|
|
||||||
|
|
||||||
bool openFile(const QString &fileName);
|
bool openFile(const QString &fileName);
|
||||||
|
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
InfoItem::InfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
InfoItem::InfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||||
{
|
{
|
||||||
|
_font.setPixelSize(FONT_SIZE);
|
||||||
|
_font.setFamily(FONT_FAMILY);
|
||||||
|
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
@ -14,16 +17,14 @@ InfoItem::InfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
|||||||
|
|
||||||
void InfoItem::updateBoundingRect()
|
void InfoItem::updateBoundingRect()
|
||||||
{
|
{
|
||||||
QFont font;
|
QFontMetrics fm(_font);
|
||||||
font.setPixelSize(FONT_SIZE);
|
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QList<KV>::const_iterator i;
|
|
||||||
qreal width = 0;
|
qreal width = 0;
|
||||||
|
|
||||||
for (i = _list.constBegin(); i != _list.constEnd(); i++) {
|
for (QList<KV>::const_iterator i = _list.constBegin();
|
||||||
|
i != _list.constEnd(); i++) {
|
||||||
width += fm.width(i->key + ": ");
|
width += fm.width(i->key + ": ");
|
||||||
width += fm.width(i->value) + ((i == _list.constEnd() - 1) ? 0 : PADDING);
|
width += fm.width(i->value) + ((i == _list.constEnd() - 1)
|
||||||
|
? 0 : PADDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
_boundingRect = QRectF(0, 0, width, _list.isEmpty() ? 0 : fm.height());
|
_boundingRect = QRectF(0, 0, width, _list.isEmpty() ? 0 : fm.height());
|
||||||
@ -34,22 +35,19 @@ void InfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
QFont font;
|
QFontMetrics fm(_font);
|
||||||
font.setPixelSize(FONT_SIZE);
|
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
painter->setFont(font);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QList<KV>::const_iterator i;
|
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
|
||||||
|
painter->setFont(_font);
|
||||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
|
||||||
for (i = _list.constBegin(); i != _list.constEnd(); i++) {
|
for (QList<KV>::const_iterator i = _list.constBegin();
|
||||||
|
i != _list.constEnd(); i++) {
|
||||||
painter->drawText(width, fm.height() - fm.descent(), i->key + ": ");
|
painter->drawText(width, fm.height() - fm.descent(), i->key + ": ");
|
||||||
width += fm.width(i->key + ": ");
|
width += fm.width(i->key + ": ");
|
||||||
painter->drawText(width, fm.height() - fm.descent(), i->value);
|
painter->drawText(width, fm.height() - fm.descent(), i->value);
|
||||||
width += fm.width(i->value) + ((i == _list.constEnd() - 1) ? 0 : PADDING);
|
width += fm.width(i->value) + ((i == _list.constEnd() - 1)
|
||||||
|
? 0 : PADDING);
|
||||||
if (i != _list.constEnd() - 1) {
|
if (i != _list.constEnd() - 1) {
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setPen(Qt::gray);
|
painter->setPen(Qt::gray);
|
||||||
|
@ -33,6 +33,7 @@ private:
|
|||||||
|
|
||||||
QList<KV> _list;
|
QList<KV> _list;
|
||||||
QRectF _boundingRect;
|
QRectF _boundingRect;
|
||||||
|
QFont _font;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INFOITEM_H
|
#endif // INFOITEM_H
|
||||||
|
@ -75,7 +75,6 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
|||||||
_plot = false;
|
_plot = false;
|
||||||
_digitalZoom = 0;
|
_digitalZoom = 0;
|
||||||
|
|
||||||
_map->setBackgroundColor(_backgroundColor);
|
|
||||||
_res = _map->resolution(_map->bounds());
|
_res = _map->resolution(_map->bounds());
|
||||||
_scene->setSceneRect(_map->bounds());
|
_scene->setSceneRect(_map->bounds());
|
||||||
|
|
||||||
@ -267,7 +266,6 @@ void MapView::setMap(Map *map)
|
|||||||
|
|
||||||
_map = map;
|
_map = map;
|
||||||
_map->load();
|
_map->load();
|
||||||
_map->setBackgroundColor(_backgroundColor);
|
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||||
|
|
||||||
digitalZoom(0);
|
digitalZoom(0);
|
||||||
@ -746,7 +744,6 @@ void MapView::setMapOpacity(int opacity)
|
|||||||
void MapView::setBackgroundColor(const QColor &color)
|
void MapView::setBackgroundColor(const QColor &color)
|
||||||
{
|
{
|
||||||
_backgroundColor = color;
|
_backgroundColor = color;
|
||||||
_map->setBackgroundColor(color);
|
|
||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,9 +311,25 @@ QWidget *OptionsDialog::createDataPage()
|
|||||||
pauseTab->setLayout(pauseLayout);
|
pauseTab->setLayout(pauseLayout);
|
||||||
|
|
||||||
|
|
||||||
|
_computed = new QRadioButton(tr("Computed from distance/time"));
|
||||||
|
_reported = new QRadioButton(tr("Recorded by device"));
|
||||||
|
if (_options->useReportedSpeed)
|
||||||
|
_reported->setChecked(true);
|
||||||
|
else
|
||||||
|
_computed->setChecked(true);
|
||||||
|
|
||||||
|
QFormLayout *sourceLayout = new QFormLayout();
|
||||||
|
sourceLayout->addWidget(_computed);
|
||||||
|
sourceLayout->addWidget(_reported);
|
||||||
|
|
||||||
|
QWidget *sourceTab = new QWidget();
|
||||||
|
sourceTab->setLayout(sourceLayout);
|
||||||
|
|
||||||
|
|
||||||
QTabWidget *filterPage = new QTabWidget();
|
QTabWidget *filterPage = new QTabWidget();
|
||||||
filterPage->addTab(filterTab, tr("Filtering"));
|
filterPage->addTab(filterTab, tr("Filtering"));
|
||||||
filterPage->addTab(pauseTab, tr("Pause detection"));
|
filterPage->addTab(pauseTab, tr("Pause detection"));
|
||||||
|
filterPage->addTab(sourceTab, tr("Speed"));
|
||||||
|
|
||||||
return filterPage;
|
return filterPage;
|
||||||
}
|
}
|
||||||
@ -543,6 +559,7 @@ void OptionsDialog::accept()
|
|||||||
if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01)
|
if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01)
|
||||||
_options->pauseSpeed = pauseSpeed;
|
_options->pauseSpeed = pauseSpeed;
|
||||||
_options->pauseInterval = _pauseInterval->value();
|
_options->pauseInterval = _pauseInterval->value();
|
||||||
|
_options->useReportedSpeed = _reported->isChecked();
|
||||||
|
|
||||||
qreal poiRadius = (_options->units == Imperial)
|
qreal poiRadius = (_options->units == Imperial)
|
||||||
? _poiRadius->value() * MIINM : (_options->units == Nautical)
|
? _poiRadius->value() * MIINM : (_options->units == Nautical)
|
||||||
|
@ -43,6 +43,7 @@ struct Options {
|
|||||||
bool outlierEliminate;
|
bool outlierEliminate;
|
||||||
qreal pauseSpeed;
|
qreal pauseSpeed;
|
||||||
int pauseInterval;
|
int pauseInterval;
|
||||||
|
bool useReportedSpeed;
|
||||||
// POI
|
// POI
|
||||||
int poiRadius;
|
int poiRadius;
|
||||||
// System
|
// System
|
||||||
@ -110,6 +111,8 @@ private:
|
|||||||
QCheckBox *_outlierEliminate;
|
QCheckBox *_outlierEliminate;
|
||||||
QDoubleSpinBox *_pauseSpeed;
|
QDoubleSpinBox *_pauseSpeed;
|
||||||
QSpinBox *_pauseInterval;
|
QSpinBox *_pauseInterval;
|
||||||
|
QRadioButton *_computed;
|
||||||
|
QRadioButton *_reported;
|
||||||
// POI
|
// POI
|
||||||
QDoubleSpinBox *_poiRadius;
|
QDoubleSpinBox *_poiRadius;
|
||||||
// System
|
// System
|
||||||
|
@ -175,10 +175,10 @@ void PathItem::setMarkerColor(const QColor &color)
|
|||||||
void PathItem::hover(bool hover)
|
void PathItem::hover(bool hover)
|
||||||
{
|
{
|
||||||
if (hover) {
|
if (hover) {
|
||||||
_pen.setWidth(_width + 1);
|
_pen.setWidth((_width + 1) * pow(2, -_digitalZoom));
|
||||||
setZValue(zValue() + 1.0);
|
setZValue(zValue() + 1.0);
|
||||||
} else {
|
} else {
|
||||||
_pen.setWidth(_width);
|
_pen.setWidth(_width * pow(2, -_digitalZoom));
|
||||||
setZValue(zValue() - 1.0);
|
setZValue(zValue() - 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,52 +18,34 @@ ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
|||||||
_res = 1.0;
|
_res = 1.0;
|
||||||
_digitalZoom = 0;
|
_digitalZoom = 0;
|
||||||
|
|
||||||
|
_font.setPixelSize(FONT_SIZE);
|
||||||
|
_font.setFamily(FONT_FAMILY);
|
||||||
|
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleItem::updateBoundingRect()
|
|
||||||
{
|
|
||||||
QFont font;
|
|
||||||
font.setPixelSize(FONT_SIZE);
|
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRect ss, es, us;
|
|
||||||
|
|
||||||
ss = fm.tightBoundingRect(QString::number(0));
|
|
||||||
es = fm.tightBoundingRect(QString::number(_length * SEGMENTS));
|
|
||||||
us = fm.tightBoundingRect(units());
|
|
||||||
|
|
||||||
_boundingRect = QRectF(-ss.width()/2, 0, _width * SEGMENTS + ss.width()/2
|
|
||||||
+ qMax(us.width() + PADDING, es.width()/2) + 1, SCALE_HEIGHT + PADDING
|
|
||||||
+ ss.height() + 2*fm.descent());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget)
|
QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
QFont font;
|
QFontMetrics fm(_font);
|
||||||
font.setPixelSize(FONT_SIZE);
|
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRect br;
|
QRect br;
|
||||||
QPen pen = QPen(Qt::black, BORDER_WIDTH);
|
|
||||||
|
|
||||||
|
|
||||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
painter->setFont(font);
|
painter->setFont(_font);
|
||||||
painter->setPen(pen);
|
painter->setPen(QPen(Qt::black, BORDER_WIDTH));
|
||||||
|
|
||||||
for (int i = 0; i <= SEGMENTS; i++) {
|
for (int i = 0; i < _ticks.size(); i++) {
|
||||||
QString label = QString::number(_length * i);
|
br = _ticks.at(i).boundingBox;
|
||||||
br = fm.tightBoundingRect(label);
|
painter->drawText(_width * i - br.width()/2, br.height() + 1,
|
||||||
painter->drawText(_width * i - br.width()/2, br.height() + 1, label);
|
QString::number(_ticks.at(i).value));
|
||||||
}
|
}
|
||||||
painter->drawText(_width * SEGMENTS + PADDING, SCALE_HEIGHT + PADDING
|
painter->drawText(_width * SEGMENTS + PADDING, SCALE_HEIGHT + PADDING
|
||||||
+ br.height() + fm.descent(), units());
|
+ br.height() + fm.descent(), _unitsStr);
|
||||||
|
|
||||||
painter->drawRect(QRectF(0, br.height() + PADDING, SEGMENTS * _width,
|
painter->drawRect(QRectF(0, br.height() + PADDING, SEGMENTS * _width,
|
||||||
SCALE_HEIGHT));
|
SCALE_HEIGHT));
|
||||||
@ -77,19 +59,6 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ScaleItem::units() const
|
|
||||||
{
|
|
||||||
if (_units == Imperial)
|
|
||||||
return _scale ? qApp->translate("ScaleItem", "mi")
|
|
||||||
: qApp->translate("ScaleItem", "ft");
|
|
||||||
else if (_units == Nautical)
|
|
||||||
return _scale ? qApp->translate("ScaleItem", "nmi")
|
|
||||||
: qApp->translate("ScaleItem", "ft");
|
|
||||||
else
|
|
||||||
return _scale ? qApp->translate("ScaleItem", "km")
|
|
||||||
: qApp->translate("ScaleItem", "m");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScaleItem::computeScale()
|
void ScaleItem::computeScale()
|
||||||
{
|
{
|
||||||
qreal res = _res * pow(2, -_digitalZoom);
|
qreal res = _res * pow(2, -_digitalZoom);
|
||||||
@ -127,21 +96,50 @@ void ScaleItem::computeScale()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScaleItem::updateCache()
|
||||||
|
{
|
||||||
|
QFontMetrics fm(_font);
|
||||||
|
|
||||||
|
_ticks = QVector<Tick>(SEGMENTS + 1);
|
||||||
|
for (int i = 0; i < _ticks.size(); i++) {
|
||||||
|
Tick &t = _ticks[i];
|
||||||
|
t.value = _length * i;
|
||||||
|
t.boundingBox = fm.tightBoundingRect(QString::number(t.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_units == Imperial)
|
||||||
|
_unitsStr = _scale ? qApp->translate("ScaleItem", "mi")
|
||||||
|
: qApp->translate("ScaleItem", "ft");
|
||||||
|
else if (_units == Nautical)
|
||||||
|
_unitsStr = _scale ? qApp->translate("ScaleItem", "nmi")
|
||||||
|
: qApp->translate("ScaleItem", "ft");
|
||||||
|
else
|
||||||
|
_unitsStr = _scale ? qApp->translate("ScaleItem", "km")
|
||||||
|
: qApp->translate("ScaleItem", "m");
|
||||||
|
_unitsBB = fm.tightBoundingRect(_unitsStr);
|
||||||
|
|
||||||
|
QRect ss = _ticks.isEmpty() ? QRect() : _ticks.first().boundingBox;
|
||||||
|
QRect es = _ticks.isEmpty() ? QRect() : _ticks.last().boundingBox;
|
||||||
|
_boundingRect = QRectF(-ss.width()/2, 0, _width * SEGMENTS + ss.width()/2
|
||||||
|
+ qMax(_unitsBB.width() + PADDING, es.width()/2) + 1, SCALE_HEIGHT
|
||||||
|
+ PADDING + ss.height() + 2*fm.descent());
|
||||||
|
}
|
||||||
|
|
||||||
void ScaleItem::setResolution(qreal res)
|
void ScaleItem::setResolution(qreal res)
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_res = res;
|
_res = res;
|
||||||
computeScale();
|
computeScale();
|
||||||
updateBoundingRect();
|
updateCache();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleItem::setUnits(enum Units units)
|
void ScaleItem::setUnits(Units units)
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_units = units;
|
_units = units;
|
||||||
computeScale();
|
computeScale();
|
||||||
updateBoundingRect();
|
updateCache();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +148,7 @@ void ScaleItem::setDigitalZoom(qreal zoom)
|
|||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_digitalZoom = zoom;
|
_digitalZoom = zoom;
|
||||||
computeScale();
|
computeScale();
|
||||||
updateBoundingRect();
|
updateCache();
|
||||||
update();
|
update();
|
||||||
|
|
||||||
setScale(pow(2, -_digitalZoom));
|
setScale(pow(2, -_digitalZoom));
|
||||||
|
@ -14,23 +14,29 @@ public:
|
|||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
void setResolution(qreal res);
|
void setResolution(qreal res);
|
||||||
void setUnits(enum Units units);
|
void setUnits(Units units);
|
||||||
void setDigitalZoom(qreal zoom);
|
void setDigitalZoom(qreal zoom);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateBoundingRect();
|
struct Tick {
|
||||||
|
double value;
|
||||||
|
QRect boundingBox;
|
||||||
|
};
|
||||||
|
|
||||||
void computeScale();
|
void computeScale();
|
||||||
QString units() const;
|
void updateCache();
|
||||||
|
|
||||||
qreal _res;
|
qreal _res;
|
||||||
qreal _width;
|
qreal _width;
|
||||||
qreal _length;
|
qreal _length;
|
||||||
Units _units;
|
Units _units;
|
||||||
bool _scale;
|
bool _scale;
|
||||||
|
|
||||||
qreal _digitalZoom;
|
qreal _digitalZoom;
|
||||||
|
|
||||||
QRectF _boundingRect;
|
QRectF _boundingRect;
|
||||||
|
QFont _font;
|
||||||
|
QVector<Tick> _ticks;
|
||||||
|
QRect _unitsBB;
|
||||||
|
QString _unitsStr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCALEITEM_H
|
#endif // SCALEITEM_H
|
||||||
|
@ -124,6 +124,8 @@
|
|||||||
#define PAUSE_SPEED_DEFAULT 0.5 /* m/s */
|
#define PAUSE_SPEED_DEFAULT 0.5 /* m/s */
|
||||||
#define PAUSE_INTERVAL_SETTING "pauseInterval"
|
#define PAUSE_INTERVAL_SETTING "pauseInterval"
|
||||||
#define PAUSE_INTERVAL_DEFAULT 10 /* s */
|
#define PAUSE_INTERVAL_DEFAULT 10 /* s */
|
||||||
|
#define USE_REPORTED_SPEED_SETTING "useReportedSpeed"
|
||||||
|
#define USE_REPORTED_SPEED_DEFAULT false
|
||||||
#define POI_RADIUS_SETTING "poiRadius"
|
#define POI_RADIUS_SETTING "poiRadius"
|
||||||
#define POI_RADIUS_DEFAULT (int)(IMPERIAL_UNITS() ? MIINM : KMINM)
|
#define POI_RADIUS_DEFAULT (int)(IMPERIAL_UNITS() ? MIINM : KMINM)
|
||||||
#define USE_OPENGL_SETTING "useOpenGL"
|
#define USE_OPENGL_SETTING "useOpenGL"
|
||||||
|
@ -9,14 +9,14 @@ SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
|||||||
{
|
{
|
||||||
_side = Right;
|
_side = Right;
|
||||||
_color = Qt::red;
|
_color = Qt::red;
|
||||||
|
|
||||||
|
_font.setPixelSize(FONT_SIZE);
|
||||||
|
_font.setFamily(FONT_FAMILY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderInfoItem::updateBoundingRect()
|
void SliderInfoItem::updateBoundingRect()
|
||||||
{
|
{
|
||||||
QFont font;
|
QFontMetrics fm(_font);
|
||||||
font.setPixelSize(FONT_SIZE);
|
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
|
|
||||||
qreal width = qMax(fm.width(_x), fm.width(_y));
|
qreal width = qMax(fm.width(_x), fm.width(_y));
|
||||||
qreal height = 2 * fm.height() - 2*fm.descent();
|
qreal height = 2 * fm.height() - 2*fm.descent();
|
||||||
@ -31,10 +31,7 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
QFont font;
|
QFontMetrics fm(_font);
|
||||||
font.setPixelSize(FONT_SIZE);
|
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRectF rx, ry;
|
QRectF rx, ry;
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +54,7 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||||||
painter->drawRect(rx);
|
painter->drawRect(rx);
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
|
|
||||||
painter->setFont(font);
|
painter->setFont(_font);
|
||||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
painter->setPen(_color);
|
painter->setPen(_color);
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ private:
|
|||||||
QString _x, _y;
|
QString _x, _y;
|
||||||
QRectF _boundingRect;
|
QRectF _boundingRect;
|
||||||
QColor _color;
|
QColor _color;
|
||||||
|
QFont _font;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SLIDERINFOITEM_H
|
#endif // SLIDERINFOITEM_H
|
||||||
|
@ -36,11 +36,13 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
|
|||||||
{
|
{
|
||||||
_waypoint = waypoint;
|
_waypoint = waypoint;
|
||||||
_showLabel = true;
|
_showLabel = true;
|
||||||
_hover = false;
|
|
||||||
_size = 8;
|
_size = 8;
|
||||||
_color = Qt::black;
|
_color = Qt::black;
|
||||||
|
|
||||||
updateShape();
|
_font.setPixelSize(FS(_size));
|
||||||
|
_font.setFamily(FONT_FAMILY);
|
||||||
|
|
||||||
|
updateCache();
|
||||||
|
|
||||||
setPos(map->ll2xy(waypoint.coordinates()));
|
setPos(map->ll2xy(waypoint.coordinates()));
|
||||||
setToolTip(toolTip(Metric, DecimalDegrees));
|
setToolTip(toolTip(Metric, DecimalDegrees));
|
||||||
@ -48,23 +50,18 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
|
|||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaypointItem::updateShape()
|
void WaypointItem::updateCache()
|
||||||
{
|
{
|
||||||
QPainterPath p;
|
QPainterPath p;
|
||||||
qreal pointSize = _hover ? HS(_size) : _size;
|
qreal pointSize = _font.bold() ? HS(_size) : _size;
|
||||||
|
|
||||||
if (_showLabel) {
|
if (_showLabel) {
|
||||||
QFont font;
|
QFontMetrics fm(_font);
|
||||||
font.setPixelSize(FS(_size));
|
_labelBB = fm.tightBoundingRect(_waypoint.name());
|
||||||
font.setFamily(FONT_FAMILY);
|
|
||||||
if (_hover)
|
|
||||||
font.setBold(true);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRect ts = fm.tightBoundingRect(_waypoint.name());
|
|
||||||
|
|
||||||
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
|
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
|
||||||
p.addRect(pointSize/2, pointSize/2,
|
p.addRect(pointSize/2, pointSize/2, _labelBB.width(), _labelBB.height()
|
||||||
ts.width(), ts.height() + fm.descent());
|
+ fm.descent());
|
||||||
} else
|
} else
|
||||||
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
|
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
|
||||||
|
|
||||||
@ -76,23 +73,14 @@ void WaypointItem::paint(QPainter *painter,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
|
qreal pointSize = _font.bold() ? HS(_size) : _size;
|
||||||
qreal pointSize = _hover ? HS(_size) : _size;
|
|
||||||
|
|
||||||
painter->setPen(_color);
|
painter->setPen(_color);
|
||||||
|
|
||||||
if (_showLabel) {
|
if (_showLabel) {
|
||||||
QFont font;
|
painter->setFont(_font);
|
||||||
font.setPixelSize(FS(_size));
|
painter->drawText(pointSize/2 - qMax(_labelBB.x(), 0), pointSize/2
|
||||||
font.setFamily(FONT_FAMILY);
|
+ _labelBB.height(), _waypoint.name());
|
||||||
if (_hover)
|
|
||||||
font.setBold(true);
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QRect ts = fm.tightBoundingRect(_waypoint.name());
|
|
||||||
|
|
||||||
painter->setFont(font);
|
|
||||||
painter->drawText(pointSize/2 - qMax(ts.x(), 0), pointSize/2
|
|
||||||
+ ts.height(), _waypoint.name());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setBrush(QBrush(_color, Qt::SolidPattern));
|
painter->setBrush(QBrush(_color, Qt::SolidPattern));
|
||||||
@ -112,7 +100,8 @@ void WaypointItem::setSize(int size)
|
|||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_size = size;
|
_size = size;
|
||||||
updateShape();
|
_font.setPixelSize(FS(_size));
|
||||||
|
updateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaypointItem::setColor(const QColor &color)
|
void WaypointItem::setColor(const QColor &color)
|
||||||
@ -136,7 +125,7 @@ void WaypointItem::showLabel(bool show)
|
|||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_showLabel = show;
|
_showLabel = show;
|
||||||
updateShape();
|
updateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaypointItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void WaypointItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
@ -144,8 +133,8 @@ void WaypointItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_hover = true;
|
_font.setBold(true);
|
||||||
updateShape();
|
updateCache();
|
||||||
setZValue(zValue() + 1.0);
|
setZValue(zValue() + 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +143,7 @@ void WaypointItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_hover = false;
|
_font.setBold(false);
|
||||||
updateShape();
|
updateCache();
|
||||||
setZValue(zValue() - 1.0);
|
setZValue(zValue() - 1.0);
|
||||||
}
|
}
|
||||||
|
@ -31,16 +31,16 @@ private:
|
|||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
void updateShape();
|
void updateCache();
|
||||||
QString toolTip(Units units, CoordinatesFormat format);
|
QString toolTip(Units units, CoordinatesFormat format);
|
||||||
|
|
||||||
QPainterPath _shape;
|
|
||||||
Waypoint _waypoint;
|
Waypoint _waypoint;
|
||||||
|
QPainterPath _shape;
|
||||||
QColor _color;
|
QColor _color;
|
||||||
int _size;
|
int _size;
|
||||||
bool _hover;
|
|
||||||
bool _showLabel;
|
bool _showLabel;
|
||||||
|
QFont _font;
|
||||||
|
QRect _labelBB;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WAYPOINTITEM_H
|
#endif // WAYPOINTITEM_H
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#ifndef M_PI
|
|
||||||
#define M_PI 3.14159265358979323846
|
|
||||||
#endif // M_PI
|
|
||||||
#define deg2rad(d) (((d)*M_PI)/180.0)
|
#define deg2rad(d) (((d)*M_PI)/180.0)
|
||||||
#define rad2deg(d) (((d)*180.0)/M_PI)
|
#define rad2deg(d) (((d)*180.0)/M_PI)
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ RectC::RectC(const Coordinates ¢er, double radius)
|
|||||||
double deltaLon = asin(sin(radDist) / cos(radlat));
|
double deltaLon = asin(sin(radDist) / cos(radlat));
|
||||||
minLon = radLon - deltaLon;
|
minLon = radLon - deltaLon;
|
||||||
if (minLon < MIN_LON)
|
if (minLon < MIN_LON)
|
||||||
minLon += 2.0 * M_PI;
|
minLon += M_2_PI;
|
||||||
maxLon = radLon + deltaLon;
|
maxLon = radLon + deltaLon;
|
||||||
if (maxLon > MAX_LON)
|
if (maxLon > MAX_LON)
|
||||||
maxLon -= 2.0 * M_PI;
|
maxLon -= M_2_PI;
|
||||||
} else {
|
} else {
|
||||||
// a pole is within the distance
|
// a pole is within the distance
|
||||||
minLat = qMax(minLat, MIN_LAT);
|
minLat = qMax(minLat, MIN_LAT);
|
||||||
|
@ -3,15 +3,9 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cassert>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
#define ASSERT assert // RTree uses ASSERT( condition )
|
|
||||||
|
|
||||||
#define Max(a,b) \
|
|
||||||
(((a) > (b)) ? (a) : (b))
|
|
||||||
#define Min(a,b) \
|
|
||||||
(((a) < (b)) ? (a) : (b))
|
|
||||||
|
|
||||||
#define RTREE_TEMPLATE template<class DATATYPE, class ELEMTYPE, int NUMDIMS, \
|
#define RTREE_TEMPLATE template<class DATATYPE, class ELEMTYPE, int NUMDIMS, \
|
||||||
class ELEMTYPEREAL, int TMAXNODES, int TMINNODES>
|
class ELEMTYPEREAL, int TMAXNODES, int TMINNODES>
|
||||||
@ -129,7 +123,7 @@ public:
|
|||||||
/// Access the current data element.
|
/// Access the current data element.
|
||||||
DATATYPE& operator*()
|
DATATYPE& operator*()
|
||||||
{
|
{
|
||||||
ASSERT(IsNotNull());
|
Q_ASSERT(IsNotNull());
|
||||||
StackElement& curTos = m_stack[m_tos - 1];
|
StackElement& curTos = m_stack[m_tos - 1];
|
||||||
return curTos.m_node->m_branch[curTos.m_branchIndex].m_data;
|
return curTos.m_node->m_branch[curTos.m_branchIndex].m_data;
|
||||||
}
|
}
|
||||||
@ -137,7 +131,7 @@ public:
|
|||||||
/// Access the current data element.
|
/// Access the current data element.
|
||||||
const DATATYPE& operator*() const
|
const DATATYPE& operator*() const
|
||||||
{
|
{
|
||||||
ASSERT(IsNotNull());
|
Q_ASSERT(IsNotNull());
|
||||||
StackElement& curTos = m_stack[m_tos - 1];
|
StackElement& curTos = m_stack[m_tos - 1];
|
||||||
return curTos.m_node->m_branch[curTos.m_branchIndex].m_data;
|
return curTos.m_node->m_branch[curTos.m_branchIndex].m_data;
|
||||||
}
|
}
|
||||||
@ -148,7 +142,7 @@ public:
|
|||||||
/// Get the bounds for this node
|
/// Get the bounds for this node
|
||||||
void GetBounds(ELEMTYPE a_min[NUMDIMS], ELEMTYPE a_max[NUMDIMS])
|
void GetBounds(ELEMTYPE a_min[NUMDIMS], ELEMTYPE a_max[NUMDIMS])
|
||||||
{
|
{
|
||||||
ASSERT(IsNotNull());
|
Q_ASSERT(IsNotNull());
|
||||||
StackElement& curTos = m_stack[m_tos - 1];
|
StackElement& curTos = m_stack[m_tos - 1];
|
||||||
Branch& curBranch = curTos.m_node->m_branch[curTos.m_branchIndex];
|
Branch& curBranch = curTos.m_node->m_branch[curTos.m_branchIndex];
|
||||||
|
|
||||||
@ -206,13 +200,13 @@ public:
|
|||||||
m_stack[m_tos].m_node = a_node;
|
m_stack[m_tos].m_node = a_node;
|
||||||
m_stack[m_tos].m_branchIndex = a_branchIndex;
|
m_stack[m_tos].m_branchIndex = a_branchIndex;
|
||||||
++m_tos;
|
++m_tos;
|
||||||
ASSERT(m_tos <= MAX_STACK);
|
Q_ASSERT(m_tos <= MAX_STACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pop element off iteration stack
|
// Pop element off iteration stack
|
||||||
StackElement& Pop()
|
StackElement& Pop()
|
||||||
{
|
{
|
||||||
ASSERT(m_tos > 0);
|
Q_ASSERT(m_tos > 0);
|
||||||
--m_tos;
|
--m_tos;
|
||||||
return m_stack[m_tos];
|
return m_stack[m_tos];
|
||||||
}
|
}
|
||||||
@ -356,12 +350,12 @@ protected:
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
RTREE_QUAL::RTree()
|
RTREE_QUAL::RTree()
|
||||||
{
|
{
|
||||||
ASSERT(MAXNODES > MINNODES);
|
Q_ASSERT(MAXNODES > MINNODES);
|
||||||
ASSERT(MINNODES > 0);
|
Q_ASSERT(MINNODES > 0);
|
||||||
|
|
||||||
// We only support machine word size simple data type eg. integer index or
|
// We only support machine word size simple data type eg. integer index or
|
||||||
// object pointer. Since we are storing as union with non data branch
|
// object pointer. Since we are storing as union with non data branch
|
||||||
ASSERT(sizeof(DATATYPE) == sizeof(void*) || sizeof(DATATYPE) == sizeof(int));
|
Q_ASSERT(sizeof(DATATYPE) == sizeof(void*) || sizeof(DATATYPE) == sizeof(int));
|
||||||
|
|
||||||
// Precomputed volumes of the unit spheres for the first few dimensions
|
// Precomputed volumes of the unit spheres for the first few dimensions
|
||||||
const float UNIT_SPHERE_VOLUMES[] = {
|
const float UNIT_SPHERE_VOLUMES[] = {
|
||||||
@ -393,7 +387,7 @@ void RTREE_QUAL::Insert(const ELEMTYPE a_min[NUMDIMS],
|
|||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
for (int index=0; index<NUMDIMS; ++index)
|
for (int index=0; index<NUMDIMS; ++index)
|
||||||
ASSERT(a_min[index] <= a_max[index]);
|
Q_ASSERT(a_min[index] <= a_max[index]);
|
||||||
#endif //_DEBUG
|
#endif //_DEBUG
|
||||||
|
|
||||||
Rect rect;
|
Rect rect;
|
||||||
@ -413,7 +407,7 @@ void RTREE_QUAL::Remove(const ELEMTYPE a_min[NUMDIMS],
|
|||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
for (int index=0; index<NUMDIMS; ++index)
|
for (int index=0; index<NUMDIMS; ++index)
|
||||||
ASSERT(a_min[index] <= a_max[index]);
|
Q_ASSERT(a_min[index] <= a_max[index]);
|
||||||
#endif //_DEBUG
|
#endif //_DEBUG
|
||||||
|
|
||||||
Rect rect;
|
Rect rect;
|
||||||
@ -433,7 +427,7 @@ int RTREE_QUAL::Search(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDI
|
|||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
for (int index=0; index<NUMDIMS; ++index)
|
for (int index=0; index<NUMDIMS; ++index)
|
||||||
ASSERT(a_min[index] <= a_max[index]);
|
Q_ASSERT(a_min[index] <= a_max[index]);
|
||||||
#endif //_DEBUG
|
#endif //_DEBUG
|
||||||
|
|
||||||
Rect rect;
|
Rect rect;
|
||||||
@ -502,8 +496,8 @@ void RTREE_QUAL::Reset()
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
void RTREE_QUAL::RemoveAllRec(Node* a_node)
|
void RTREE_QUAL::RemoveAllRec(Node* a_node)
|
||||||
{
|
{
|
||||||
ASSERT(a_node);
|
Q_ASSERT(a_node);
|
||||||
ASSERT(a_node->m_level >= 0);
|
Q_ASSERT(a_node->m_level >= 0);
|
||||||
|
|
||||||
if (a_node->IsInternalNode()) { // This is an internal node in the tree
|
if (a_node->IsInternalNode()) { // This is an internal node in the tree
|
||||||
for (int index=0; index < a_node->m_count; ++index)
|
for (int index=0; index < a_node->m_count; ++index)
|
||||||
@ -530,7 +524,7 @@ typename RTREE_QUAL::Node* RTREE_QUAL::AllocNode()
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
void RTREE_QUAL::FreeNode(Node* a_node)
|
void RTREE_QUAL::FreeNode(Node* a_node)
|
||||||
{
|
{
|
||||||
ASSERT(a_node);
|
Q_ASSERT(a_node);
|
||||||
|
|
||||||
#ifdef RTREE_DONT_USE_MEMPOOLS
|
#ifdef RTREE_DONT_USE_MEMPOOLS
|
||||||
delete a_node;
|
delete a_node;
|
||||||
@ -593,8 +587,8 @@ RTREE_TEMPLATE
|
|||||||
bool RTREE_QUAL::InsertRectRec(Rect* a_rect, const DATATYPE& a_id, Node* a_node,
|
bool RTREE_QUAL::InsertRectRec(Rect* a_rect, const DATATYPE& a_id, Node* a_node,
|
||||||
Node** a_newNode, int a_level)
|
Node** a_newNode, int a_level)
|
||||||
{
|
{
|
||||||
ASSERT(a_rect && a_node && a_newNode);
|
Q_ASSERT(a_rect && a_node && a_newNode);
|
||||||
ASSERT(a_level >= 0 && a_level <= a_node->m_level);
|
Q_ASSERT(a_level >= 0 && a_level <= a_node->m_level);
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
Branch branch;
|
Branch branch;
|
||||||
@ -621,7 +615,7 @@ bool RTREE_QUAL::InsertRectRec(Rect* a_rect, const DATATYPE& a_id, Node* a_node,
|
|||||||
return AddBranch(&branch, a_node, a_newNode);
|
return AddBranch(&branch, a_node, a_newNode);
|
||||||
} else {
|
} else {
|
||||||
// Should never occur
|
// Should never occur
|
||||||
ASSERT(0);
|
Q_ASSERT(0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -638,11 +632,11 @@ RTREE_TEMPLATE
|
|||||||
bool RTREE_QUAL::InsertRect(Rect* a_rect, const DATATYPE& a_id, Node** a_root,
|
bool RTREE_QUAL::InsertRect(Rect* a_rect, const DATATYPE& a_id, Node** a_root,
|
||||||
int a_level)
|
int a_level)
|
||||||
{
|
{
|
||||||
ASSERT(a_rect && a_root);
|
Q_ASSERT(a_rect && a_root);
|
||||||
ASSERT(a_level >= 0 && a_level <= (*a_root)->m_level);
|
Q_ASSERT(a_level >= 0 && a_level <= (*a_root)->m_level);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
for (int index=0; index < NUMDIMS; ++index)
|
for (int index=0; index < NUMDIMS; ++index)
|
||||||
ASSERT(a_rect->m_min[index] <= a_rect->m_max[index]);
|
Q_ASSERT(a_rect->m_min[index] <= a_rect->m_max[index]);
|
||||||
#endif //_DEBUG
|
#endif //_DEBUG
|
||||||
|
|
||||||
Node* newRoot;
|
Node* newRoot;
|
||||||
@ -672,7 +666,7 @@ bool RTREE_QUAL::InsertRect(Rect* a_rect, const DATATYPE& a_id, Node** a_root,
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
typename RTREE_QUAL::Rect RTREE_QUAL::NodeCover(Node* a_node)
|
typename RTREE_QUAL::Rect RTREE_QUAL::NodeCover(Node* a_node)
|
||||||
{
|
{
|
||||||
ASSERT(a_node);
|
Q_ASSERT(a_node);
|
||||||
|
|
||||||
int firstTime = true;
|
int firstTime = true;
|
||||||
Rect rect;
|
Rect rect;
|
||||||
@ -698,8 +692,8 @@ typename RTREE_QUAL::Rect RTREE_QUAL::NodeCover(Node* a_node)
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
bool RTREE_QUAL::AddBranch(Branch* a_branch, Node* a_node, Node** a_newNode)
|
bool RTREE_QUAL::AddBranch(Branch* a_branch, Node* a_node, Node** a_newNode)
|
||||||
{
|
{
|
||||||
ASSERT(a_branch);
|
Q_ASSERT(a_branch);
|
||||||
ASSERT(a_node);
|
Q_ASSERT(a_node);
|
||||||
|
|
||||||
if (a_node->m_count < MAXNODES) { // Split won't be necessary
|
if (a_node->m_count < MAXNODES) { // Split won't be necessary
|
||||||
a_node->m_branch[a_node->m_count] = *a_branch;
|
a_node->m_branch[a_node->m_count] = *a_branch;
|
||||||
@ -707,7 +701,7 @@ bool RTREE_QUAL::AddBranch(Branch* a_branch, Node* a_node, Node** a_newNode)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(a_newNode);
|
Q_ASSERT(a_newNode);
|
||||||
|
|
||||||
SplitNode(a_node, a_branch, a_newNode);
|
SplitNode(a_node, a_branch, a_newNode);
|
||||||
return true;
|
return true;
|
||||||
@ -721,8 +715,8 @@ bool RTREE_QUAL::AddBranch(Branch* a_branch, Node* a_node, Node** a_newNode)
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
void RTREE_QUAL::DisconnectBranch(Node* a_node, int a_index)
|
void RTREE_QUAL::DisconnectBranch(Node* a_node, int a_index)
|
||||||
{
|
{
|
||||||
ASSERT(a_node && (a_index >= 0) && (a_index < MAXNODES));
|
Q_ASSERT(a_node && (a_index >= 0) && (a_index < MAXNODES));
|
||||||
ASSERT(a_node->m_count > 0);
|
Q_ASSERT(a_node->m_count > 0);
|
||||||
|
|
||||||
// Remove element by swapping with the last element to prevent gaps in array
|
// Remove element by swapping with the last element to prevent gaps in array
|
||||||
a_node->m_branch[a_index] = a_node->m_branch[a_node->m_count - 1];
|
a_node->m_branch[a_index] = a_node->m_branch[a_node->m_count - 1];
|
||||||
@ -739,7 +733,7 @@ void RTREE_QUAL::DisconnectBranch(Node* a_node, int a_index)
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
int RTREE_QUAL::PickBranch(Rect* a_rect, Node* a_node)
|
int RTREE_QUAL::PickBranch(Rect* a_rect, Node* a_node)
|
||||||
{
|
{
|
||||||
ASSERT(a_rect && a_node);
|
Q_ASSERT(a_rect && a_node);
|
||||||
|
|
||||||
bool firstTime = true;
|
bool firstTime = true;
|
||||||
ELEMTYPEREAL increase;
|
ELEMTYPEREAL increase;
|
||||||
@ -774,13 +768,13 @@ int RTREE_QUAL::PickBranch(Rect* a_rect, Node* a_node)
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
typename RTREE_QUAL::Rect RTREE_QUAL::CombineRect(Rect* a_rectA, Rect* a_rectB)
|
typename RTREE_QUAL::Rect RTREE_QUAL::CombineRect(Rect* a_rectA, Rect* a_rectB)
|
||||||
{
|
{
|
||||||
ASSERT(a_rectA && a_rectB);
|
Q_ASSERT(a_rectA && a_rectB);
|
||||||
|
|
||||||
Rect newRect;
|
Rect newRect;
|
||||||
|
|
||||||
for (int index = 0; index < NUMDIMS; ++index) {
|
for (int index = 0; index < NUMDIMS; ++index) {
|
||||||
newRect.m_min[index] = Min(a_rectA->m_min[index], a_rectB->m_min[index]);
|
newRect.m_min[index] = qMin(a_rectA->m_min[index], a_rectB->m_min[index]);
|
||||||
newRect.m_max[index] = Max(a_rectA->m_max[index], a_rectB->m_max[index]);
|
newRect.m_max[index] = qMax(a_rectA->m_max[index], a_rectB->m_max[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newRect;
|
return newRect;
|
||||||
@ -795,8 +789,8 @@ typename RTREE_QUAL::Rect RTREE_QUAL::CombineRect(Rect* a_rectA, Rect* a_rectB)
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
void RTREE_QUAL::SplitNode(Node* a_node, Branch* a_branch, Node** a_newNode)
|
void RTREE_QUAL::SplitNode(Node* a_node, Branch* a_branch, Node** a_newNode)
|
||||||
{
|
{
|
||||||
ASSERT(a_node);
|
Q_ASSERT(a_node);
|
||||||
ASSERT(a_branch);
|
Q_ASSERT(a_branch);
|
||||||
|
|
||||||
// Could just use local here, but member or external is faster since it is
|
// Could just use local here, but member or external is faster since it is
|
||||||
// reused
|
// reused
|
||||||
@ -816,7 +810,7 @@ void RTREE_QUAL::SplitNode(Node* a_node, Branch* a_branch, Node** a_newNode)
|
|||||||
(*a_newNode)->m_level = a_node->m_level = level;
|
(*a_newNode)->m_level = a_node->m_level = level;
|
||||||
LoadNodes(a_node, *a_newNode, parVars);
|
LoadNodes(a_node, *a_newNode, parVars);
|
||||||
|
|
||||||
ASSERT((a_node->m_count + (*a_newNode)->m_count) == parVars->m_total);
|
Q_ASSERT((a_node->m_count + (*a_newNode)->m_count) == parVars->m_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -824,14 +818,14 @@ void RTREE_QUAL::SplitNode(Node* a_node, Branch* a_branch, Node** a_newNode)
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
ELEMTYPEREAL RTREE_QUAL::RectVolume(Rect* a_rect)
|
ELEMTYPEREAL RTREE_QUAL::RectVolume(Rect* a_rect)
|
||||||
{
|
{
|
||||||
ASSERT(a_rect);
|
Q_ASSERT(a_rect);
|
||||||
|
|
||||||
ELEMTYPEREAL volume = (ELEMTYPEREAL)1;
|
ELEMTYPEREAL volume = (ELEMTYPEREAL)1;
|
||||||
|
|
||||||
for (int index=0; index<NUMDIMS; ++index)
|
for (int index=0; index<NUMDIMS; ++index)
|
||||||
volume *= a_rect->m_max[index] - a_rect->m_min[index];
|
volume *= a_rect->m_max[index] - a_rect->m_min[index];
|
||||||
|
|
||||||
ASSERT(volume >= (ELEMTYPEREAL)0);
|
Q_ASSERT(volume >= (ELEMTYPEREAL)0);
|
||||||
|
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
@ -841,7 +835,7 @@ ELEMTYPEREAL RTREE_QUAL::RectVolume(Rect* a_rect)
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
ELEMTYPEREAL RTREE_QUAL::RectSphericalVolume(Rect* a_rect)
|
ELEMTYPEREAL RTREE_QUAL::RectSphericalVolume(Rect* a_rect)
|
||||||
{
|
{
|
||||||
ASSERT(a_rect);
|
Q_ASSERT(a_rect);
|
||||||
|
|
||||||
ELEMTYPEREAL sumOfSquares = (ELEMTYPEREAL)0;
|
ELEMTYPEREAL sumOfSquares = (ELEMTYPEREAL)0;
|
||||||
ELEMTYPEREAL radius;
|
ELEMTYPEREAL radius;
|
||||||
@ -881,10 +875,10 @@ RTREE_TEMPLATE
|
|||||||
void RTREE_QUAL::GetBranches(Node* a_node, Branch* a_branch,
|
void RTREE_QUAL::GetBranches(Node* a_node, Branch* a_branch,
|
||||||
PartitionVars* a_parVars)
|
PartitionVars* a_parVars)
|
||||||
{
|
{
|
||||||
ASSERT(a_node);
|
Q_ASSERT(a_node);
|
||||||
ASSERT(a_branch);
|
Q_ASSERT(a_branch);
|
||||||
|
|
||||||
ASSERT(a_node->m_count == MAXNODES);
|
Q_ASSERT(a_node->m_count == MAXNODES);
|
||||||
|
|
||||||
// Load the branch buffer
|
// Load the branch buffer
|
||||||
for (int index=0; index < MAXNODES; ++index)
|
for (int index=0; index < MAXNODES; ++index)
|
||||||
@ -917,7 +911,7 @@ void RTREE_QUAL::GetBranches(Node* a_node, Branch* a_branch,
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
void RTREE_QUAL::ChoosePartition(PartitionVars* a_parVars, int a_minFill)
|
void RTREE_QUAL::ChoosePartition(PartitionVars* a_parVars, int a_minFill)
|
||||||
{
|
{
|
||||||
ASSERT(a_parVars);
|
Q_ASSERT(a_parVars);
|
||||||
|
|
||||||
ELEMTYPEREAL biggestDiff;
|
ELEMTYPEREAL biggestDiff;
|
||||||
int group, chosen = 0, betterGroup = 0;
|
int group, chosen = 0, betterGroup = 0;
|
||||||
@ -973,8 +967,8 @@ void RTREE_QUAL::ChoosePartition(PartitionVars* a_parVars, int a_minFill)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT((a_parVars->m_count[0] + a_parVars->m_count[1]) == a_parVars->m_total);
|
Q_ASSERT((a_parVars->m_count[0] + a_parVars->m_count[1]) == a_parVars->m_total);
|
||||||
ASSERT((a_parVars->m_count[0] >= a_parVars->m_minFill) &&
|
Q_ASSERT((a_parVars->m_count[0] >= a_parVars->m_minFill) &&
|
||||||
(a_parVars->m_count[1] >= a_parVars->m_minFill));
|
(a_parVars->m_count[1] >= a_parVars->m_minFill));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -983,12 +977,12 @@ void RTREE_QUAL::ChoosePartition(PartitionVars* a_parVars, int a_minFill)
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
void RTREE_QUAL::LoadNodes(Node* a_nodeA, Node* a_nodeB, PartitionVars* a_parVars)
|
void RTREE_QUAL::LoadNodes(Node* a_nodeA, Node* a_nodeB, PartitionVars* a_parVars)
|
||||||
{
|
{
|
||||||
ASSERT(a_nodeA);
|
Q_ASSERT(a_nodeA);
|
||||||
ASSERT(a_nodeB);
|
Q_ASSERT(a_nodeB);
|
||||||
ASSERT(a_parVars);
|
Q_ASSERT(a_parVars);
|
||||||
|
|
||||||
for (int index=0; index < a_parVars->m_total; ++index) {
|
for (int index=0; index < a_parVars->m_total; ++index) {
|
||||||
ASSERT(a_parVars->m_partition[index] == 0 || a_parVars->m_partition[index] == 1);
|
Q_ASSERT(a_parVars->m_partition[index] == 0 || a_parVars->m_partition[index] == 1);
|
||||||
|
|
||||||
if (a_parVars->m_partition[index] == 0)
|
if (a_parVars->m_partition[index] == 0)
|
||||||
AddBranch(&a_parVars->m_branchBuf[index], a_nodeA, NULL);
|
AddBranch(&a_parVars->m_branchBuf[index], a_nodeA, NULL);
|
||||||
@ -1003,7 +997,7 @@ RTREE_TEMPLATE
|
|||||||
void RTREE_QUAL::InitParVars(PartitionVars* a_parVars, int a_maxRects,
|
void RTREE_QUAL::InitParVars(PartitionVars* a_parVars, int a_maxRects,
|
||||||
int a_minFill)
|
int a_minFill)
|
||||||
{
|
{
|
||||||
ASSERT(a_parVars);
|
Q_ASSERT(a_parVars);
|
||||||
|
|
||||||
a_parVars->m_count[0] = a_parVars->m_count[1] = 0;
|
a_parVars->m_count[0] = a_parVars->m_count[1] = 0;
|
||||||
a_parVars->m_area[0] = a_parVars->m_area[1] = (ELEMTYPEREAL)0;
|
a_parVars->m_area[0] = a_parVars->m_area[1] = (ELEMTYPEREAL)0;
|
||||||
@ -1049,8 +1043,8 @@ void RTREE_QUAL::PickSeeds(PartitionVars* a_parVars)
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
void RTREE_QUAL::Classify(int a_index, int a_group, PartitionVars* a_parVars)
|
void RTREE_QUAL::Classify(int a_index, int a_group, PartitionVars* a_parVars)
|
||||||
{
|
{
|
||||||
ASSERT(a_parVars);
|
Q_ASSERT(a_parVars);
|
||||||
ASSERT(!a_parVars->m_taken[a_index]);
|
Q_ASSERT(!a_parVars->m_taken[a_index]);
|
||||||
|
|
||||||
a_parVars->m_partition[a_index] = a_group;
|
a_parVars->m_partition[a_index] = a_group;
|
||||||
a_parVars->m_taken[a_index] = true;
|
a_parVars->m_taken[a_index] = true;
|
||||||
@ -1073,8 +1067,8 @@ void RTREE_QUAL::Classify(int a_index, int a_group, PartitionVars* a_parVars)
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
bool RTREE_QUAL::RemoveRect(Rect* a_rect, const DATATYPE& a_id, Node** a_root)
|
bool RTREE_QUAL::RemoveRect(Rect* a_rect, const DATATYPE& a_id, Node** a_root)
|
||||||
{
|
{
|
||||||
ASSERT(a_rect && a_root);
|
Q_ASSERT(a_rect && a_root);
|
||||||
ASSERT(*a_root);
|
Q_ASSERT(*a_root);
|
||||||
|
|
||||||
Node* tempNode;
|
Node* tempNode;
|
||||||
ListNode* reInsertList = NULL;
|
ListNode* reInsertList = NULL;
|
||||||
@ -1100,7 +1094,7 @@ bool RTREE_QUAL::RemoveRect(Rect* a_rect, const DATATYPE& a_id, Node** a_root)
|
|||||||
if ((*a_root)->m_count == 1 && (*a_root)->IsInternalNode()) {
|
if ((*a_root)->m_count == 1 && (*a_root)->IsInternalNode()) {
|
||||||
tempNode = (*a_root)->m_branch[0].m_child;
|
tempNode = (*a_root)->m_branch[0].m_child;
|
||||||
|
|
||||||
ASSERT(tempNode);
|
Q_ASSERT(tempNode);
|
||||||
FreeNode(*a_root);
|
FreeNode(*a_root);
|
||||||
*a_root = tempNode;
|
*a_root = tempNode;
|
||||||
}
|
}
|
||||||
@ -1119,8 +1113,8 @@ RTREE_TEMPLATE
|
|||||||
bool RTREE_QUAL::RemoveRectRec(Rect* a_rect, const DATATYPE& a_id, Node* a_node,
|
bool RTREE_QUAL::RemoveRectRec(Rect* a_rect, const DATATYPE& a_id, Node* a_node,
|
||||||
ListNode** a_listNode)
|
ListNode** a_listNode)
|
||||||
{
|
{
|
||||||
ASSERT(a_rect && a_node && a_listNode);
|
Q_ASSERT(a_rect && a_node && a_listNode);
|
||||||
ASSERT(a_node->m_level >= 0);
|
Q_ASSERT(a_node->m_level >= 0);
|
||||||
|
|
||||||
if (a_node->IsInternalNode()) { // not a leaf node
|
if (a_node->IsInternalNode()) { // not a leaf node
|
||||||
for (int index = 0; index < a_node->m_count; ++index) {
|
for (int index = 0; index < a_node->m_count; ++index) {
|
||||||
@ -1160,7 +1154,7 @@ bool RTREE_QUAL::RemoveRectRec(Rect* a_rect, const DATATYPE& a_id, Node* a_node,
|
|||||||
RTREE_TEMPLATE
|
RTREE_TEMPLATE
|
||||||
bool RTREE_QUAL::Overlap(Rect* a_rectA, Rect* a_rectB) const
|
bool RTREE_QUAL::Overlap(Rect* a_rectA, Rect* a_rectB) const
|
||||||
{
|
{
|
||||||
ASSERT(a_rectA && a_rectB);
|
Q_ASSERT(a_rectA && a_rectB);
|
||||||
|
|
||||||
for (int index=0; index < NUMDIMS; ++index) {
|
for (int index=0; index < NUMDIMS; ++index) {
|
||||||
if (a_rectA->m_min[index] > a_rectB->m_max[index] ||
|
if (a_rectA->m_min[index] > a_rectB->m_max[index] ||
|
||||||
@ -1193,9 +1187,9 @@ bool RTREE_QUAL::Search(Node* a_node, Rect* a_rect, int& a_foundCount,
|
|||||||
bool (*a_resultCallback)(DATATYPE a_data, void* a_context),
|
bool (*a_resultCallback)(DATATYPE a_data, void* a_context),
|
||||||
void* a_context) const
|
void* a_context) const
|
||||||
{
|
{
|
||||||
ASSERT(a_node);
|
Q_ASSERT(a_node);
|
||||||
ASSERT(a_node->m_level >= 0);
|
Q_ASSERT(a_node->m_level >= 0);
|
||||||
ASSERT(a_rect);
|
Q_ASSERT(a_rect);
|
||||||
|
|
||||||
if (a_node->IsInternalNode()) { // This is an internal node in the tree
|
if (a_node->IsInternalNode()) { // This is an internal node in the tree
|
||||||
for (int index=0; index < a_node->m_count; ++index) {
|
for (int index=0; index < a_node->m_count; ++index) {
|
@ -1,48 +1,72 @@
|
|||||||
#include <cstring>
|
|
||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
#include "common/staticassert.h"
|
#include "common/staticassert.h"
|
||||||
#include "fitparser.h"
|
#include "fitparser.h"
|
||||||
|
|
||||||
|
|
||||||
const quint32 FIT_MAGIC = 0x5449462E; // .FIT
|
#define FIT_MAGIC 0x5449462E // .FIT
|
||||||
|
|
||||||
#define RECORD_MESSAGE 20
|
#define RECORD_MESSAGE 20
|
||||||
|
#define EVENT_MESSAGE 21
|
||||||
#define TIMESTAMP_FIELD 253
|
#define TIMESTAMP_FIELD 253
|
||||||
|
|
||||||
|
class Event {
|
||||||
|
public:
|
||||||
|
Event() : id(0), type(0), data(0) {}
|
||||||
|
|
||||||
FITParser::FITParser()
|
quint8 id;
|
||||||
{
|
quint8 type;
|
||||||
memset(_defs, 0, sizeof(_defs));
|
quint32 data;
|
||||||
|
};
|
||||||
|
|
||||||
_device = 0;
|
struct FileHeader {
|
||||||
_endian = 0;
|
quint8 headerSize;
|
||||||
_timestamp = 0;
|
quint8 protocolVersion;
|
||||||
_len = 0;
|
quint16 profileVersion;
|
||||||
}
|
quint32 dataSize;
|
||||||
|
quint32 magic;
|
||||||
|
};
|
||||||
|
|
||||||
void FITParser::clearDefinitions()
|
struct FITParser::Field {
|
||||||
{
|
quint8 id;
|
||||||
for (int i = 0; i < 16; i++) {
|
quint8 size;
|
||||||
if (_defs[i].fields)
|
quint8 type;
|
||||||
delete[] _defs[i].fields;
|
};
|
||||||
if (_defs[i].devFields)
|
|
||||||
delete[] _defs[i].devFields;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(_defs, 0, sizeof(_defs));
|
class FITParser::MessageDefinition {
|
||||||
}
|
public:
|
||||||
|
MessageDefinition() : endian(0), globalId(0), numFields(0), fields(0),
|
||||||
|
numDevFields(0), devFields(0) {}
|
||||||
|
~MessageDefinition() {delete[] fields; delete[] devFields;}
|
||||||
|
|
||||||
void FITParser::warning(const char *text) const
|
quint8 endian;
|
||||||
{
|
quint16 globalId;
|
||||||
const QFile *file = static_cast<QFile *>(_device);
|
quint8 numFields;
|
||||||
qWarning("%s:%d: %s\n", qPrintable(file->fileName()), _len, text);
|
Field *fields;
|
||||||
}
|
quint8 numDevFields;
|
||||||
|
Field *devFields;
|
||||||
|
};
|
||||||
|
|
||||||
bool FITParser::readData(char *data, size_t size)
|
class FITParser::CTX {
|
||||||
|
public:
|
||||||
|
CTX(QFile *file) : file(file), len(0), endian(0), timestamp(0),
|
||||||
|
lastWrite(0), ratio(NAN) {}
|
||||||
|
|
||||||
|
QFile *file;
|
||||||
|
quint32 len;
|
||||||
|
quint8 endian;
|
||||||
|
quint32 timestamp, lastWrite;
|
||||||
|
MessageDefinition defs[16];
|
||||||
|
qreal ratio;
|
||||||
|
Trackpoint trackpoint;
|
||||||
|
TrackData track;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bool FITParser::readData(QFile *file, char *data, size_t size)
|
||||||
{
|
{
|
||||||
qint64 n;
|
qint64 n;
|
||||||
|
|
||||||
n = _device->read(data, size);
|
n = file->read(data, size);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
_errorString = "I/O error";
|
_errorString = "I/O error";
|
||||||
return false;
|
return false;
|
||||||
@ -54,17 +78,17 @@ bool FITParser::readData(char *data, size_t size)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T> bool FITParser::readValue(T &val)
|
template<class T> bool FITParser::readValue(CTX &ctx, T &val)
|
||||||
{
|
{
|
||||||
T data;
|
T data;
|
||||||
|
|
||||||
if (!readData((char*)&data, sizeof(T)))
|
if (!readData(ctx.file, (char*)&data, sizeof(T)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_len -= sizeof(T);
|
ctx.len -= sizeof(T);
|
||||||
|
|
||||||
if (sizeof(T) > 1) {
|
if (sizeof(T) > 1) {
|
||||||
if (_endian)
|
if (ctx.endian)
|
||||||
val = qFromBigEndian(data);
|
val = qFromBigEndian(data);
|
||||||
else
|
else
|
||||||
val = qFromLittleEndian(data);
|
val = qFromLittleEndian(data);
|
||||||
@ -74,22 +98,16 @@ template<class T> bool FITParser::readValue(T &val)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::skipValue(size_t size)
|
bool FITParser::skipValue(CTX &ctx, size_t size)
|
||||||
{
|
{
|
||||||
size_t i;
|
ctx.len -= size;
|
||||||
quint8 val;
|
return ctx.file->seek(ctx.file->pos() + size);
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
if (!readValue(val))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseDefinitionMessage(quint8 header)
|
bool FITParser::parseDefinitionMessage(CTX &ctx, quint8 header)
|
||||||
{
|
{
|
||||||
int local_id = header & 0x0f;
|
int local_id = header & 0x0f;
|
||||||
MessageDefinition* def = &_defs[local_id];
|
MessageDefinition *def = &(ctx.defs[local_id]);
|
||||||
quint8 i;
|
quint8 i;
|
||||||
|
|
||||||
|
|
||||||
@ -103,54 +121,56 @@ bool FITParser::parseDefinitionMessage(quint8 header)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reserved/unused
|
// reserved/unused
|
||||||
if (!readValue(i))
|
if (!readValue(ctx, i))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// endianness
|
// endianness
|
||||||
if (!readValue(def->endian))
|
if (!readValue(ctx, def->endian))
|
||||||
return false;
|
return false;
|
||||||
if (def->endian > 1) {
|
if (def->endian > 1) {
|
||||||
_errorString = "Bad endian field";
|
_errorString = "Bad endian field";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_endian = def->endian;
|
ctx.endian = def->endian;
|
||||||
|
|
||||||
// global message number
|
// global message number
|
||||||
if (!readValue(def->globalId))
|
if (!readValue(ctx, def->globalId))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// number of records
|
// number of records
|
||||||
if (!readValue(def->numFields))
|
if (!readValue(ctx, def->numFields))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// definition records
|
// definition records
|
||||||
def->fields = new Field[def->numFields];
|
def->fields = new Field[def->numFields];
|
||||||
for (i = 0; i < def->numFields; i++) {
|
for (i = 0; i < def->numFields; i++) {
|
||||||
STATIC_ASSERT(sizeof(def->fields[i]) == 3);
|
STATIC_ASSERT(sizeof(def->fields[i]) == 3);
|
||||||
if (!readData((char*)&(def->fields[i]), sizeof(def->fields[i])))
|
if (!readData(ctx.file, (char*)&(def->fields[i]),
|
||||||
|
sizeof(def->fields[i])))
|
||||||
return false;
|
return false;
|
||||||
_len -= sizeof(def->fields[i]);
|
ctx.len -= sizeof(def->fields[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// developer definition records
|
// developer definition records
|
||||||
if (header & 0x20) {
|
if (header & 0x20) {
|
||||||
if (!readValue(def->numDevFields))
|
if (!readValue(ctx, def->numDevFields))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
def->devFields = new Field[def->numDevFields];
|
def->devFields = new Field[def->numDevFields];
|
||||||
for (i = 0; i < def->numDevFields; i++) {
|
for (i = 0; i < def->numDevFields; i++) {
|
||||||
STATIC_ASSERT(sizeof(def->devFields[i]) == 3);
|
STATIC_ASSERT(sizeof(def->devFields[i]) == 3);
|
||||||
if (!readData((char*)&(def->devFields[i]),
|
if (!readData(ctx.file, (char*)&(def->devFields[i]),
|
||||||
sizeof(def->devFields[i])))
|
sizeof(def->devFields[i])))
|
||||||
return false;
|
return false;
|
||||||
_len -= sizeof(def->devFields[i]);
|
ctx.len -= sizeof(def->devFields[i]);
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
def->numDevFields = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::readField(Field *f, quint32 &val)
|
bool FITParser::readField(CTX &ctx, Field *field, quint32 &val)
|
||||||
{
|
{
|
||||||
quint8 v8 = (quint8)-1;
|
quint8 v8 = (quint8)-1;
|
||||||
quint16 v16 = (quint16)-1;
|
quint16 v16 = (quint16)-1;
|
||||||
@ -158,46 +178,44 @@ bool FITParser::readField(Field *f, quint32 &val)
|
|||||||
|
|
||||||
val = (quint32)-1;
|
val = (quint32)-1;
|
||||||
|
|
||||||
switch (f->type) {
|
switch (field->type) {
|
||||||
|
case 0: // enum
|
||||||
case 1: // sint8
|
case 1: // sint8
|
||||||
case 2: // uint8
|
case 2: // uint8
|
||||||
if (f->size == 1) {
|
if (field->size == 1) {
|
||||||
ret = readValue(v8);
|
ret = readValue(ctx, v8);
|
||||||
val = v8;
|
val = v8;
|
||||||
} else
|
} else
|
||||||
ret = skipValue(f->size);
|
ret = skipValue(ctx, field->size);
|
||||||
break;
|
break;
|
||||||
case 0x83: // sint16
|
case 0x83: // sint16
|
||||||
case 0x84: // uint16
|
case 0x84: // uint16
|
||||||
if (f->size == 2) {
|
if (field->size == 2) {
|
||||||
ret = readValue(v16);
|
ret = readValue(ctx, v16);
|
||||||
val = v16;
|
val = v16;
|
||||||
} else
|
} else
|
||||||
ret = skipValue(f->size);
|
ret = skipValue(ctx, field->size);
|
||||||
break;
|
break;
|
||||||
case 0x85: // sint32
|
case 0x85: // sint32
|
||||||
case 0x86: // uint32
|
case 0x86: // uint32
|
||||||
if (f->size == 4)
|
if (field->size == 4)
|
||||||
ret = readValue(val);
|
ret = readValue(ctx, val);
|
||||||
else
|
else
|
||||||
ret = skipValue(f->size);
|
ret = skipValue(ctx, field->size);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = skipValue(f->size);
|
ret = skipValue(ctx, field->size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseData(TrackData &track, MessageDefinition *def,
|
bool FITParser::parseData(CTX &ctx, const MessageDefinition *def)
|
||||||
quint8 offset)
|
|
||||||
{
|
{
|
||||||
Field *field;
|
Field *field;
|
||||||
quint32 timestamp = _timestamp + offset;
|
Event event;
|
||||||
quint32 val;
|
quint32 val;
|
||||||
Trackpoint trackpoint;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
|
|
||||||
if (!def->fields && !def->devFields) {
|
if (!def->fields && !def->devFields) {
|
||||||
@ -205,133 +223,149 @@ bool FITParser::parseData(TrackData &track, MessageDefinition *def,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_endian = def->endian;
|
ctx.endian = def->endian;
|
||||||
|
|
||||||
for (i = 0; i < def->numFields; i++) {
|
for (int i = 0; i < def->numFields; i++) {
|
||||||
field = &def->fields[i];
|
field = &def->fields[i];
|
||||||
if (!readField(field, val))
|
if (!readField(ctx, field, val))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (field->id == TIMESTAMP_FIELD)
|
if (field->id == TIMESTAMP_FIELD)
|
||||||
_timestamp = timestamp = val;
|
ctx.timestamp = val;
|
||||||
else if (def->globalId == RECORD_MESSAGE) {
|
else if (def->globalId == RECORD_MESSAGE) {
|
||||||
switch (field->id) {
|
switch (field->id) {
|
||||||
case 0:
|
case 0:
|
||||||
if (val != 0x7fffffff)
|
if (val != 0x7fffffff)
|
||||||
trackpoint.rcoordinates().setLat(
|
ctx.trackpoint.rcoordinates().setLat(
|
||||||
((qint32)val / (double)0x7fffffff) * 180);
|
((qint32)val / (double)0x7fffffff) * 180);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (val != 0x7fffffff)
|
if (val != 0x7fffffff)
|
||||||
trackpoint.rcoordinates().setLon(
|
ctx.trackpoint.rcoordinates().setLon(
|
||||||
((qint32)val / (double)0x7fffffff) * 180);
|
((qint32)val / (double)0x7fffffff) * 180);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (val != 0xffff)
|
if (val != 0xffff)
|
||||||
trackpoint.setElevation((val / 5.0) - 500);
|
ctx.trackpoint.setElevation((val / 5.0) - 500);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (val != 0xff)
|
if (val != 0xff)
|
||||||
trackpoint.setHeartRate(val);
|
ctx.trackpoint.setHeartRate(val);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (val != 0xff)
|
if (val != 0xff)
|
||||||
trackpoint.setCadence(val);
|
ctx.trackpoint.setCadence(val);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if (val != 0xffff)
|
if (val != 0xffff)
|
||||||
trackpoint.setSpeed(val / 1000.0f);
|
ctx.trackpoint.setSpeed(val / 1000.0f);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if (val != 0xffff)
|
if (val != 0xffff)
|
||||||
trackpoint.setPower(val);
|
ctx.trackpoint.setPower(val);
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
if (val != 0x7f)
|
if (val != 0x7f)
|
||||||
trackpoint.setTemperature((qint8)val);
|
ctx.trackpoint.setTemperature((qint8)val);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else if (def->globalId == EVENT_MESSAGE) {
|
||||||
|
switch (field->id) {
|
||||||
|
case 0:
|
||||||
|
event.id = val;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
event.type = val;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
event.data = val;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < def->numDevFields; i++) {
|
for (int i = 0; i < def->numDevFields; i++) {
|
||||||
field = &def->devFields[i];
|
field = &def->devFields[i];
|
||||||
if (!readField(field, val))
|
if (!readField(ctx, field, val))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (def->globalId == RECORD_MESSAGE) {
|
if (def->globalId == EVENT_MESSAGE) {
|
||||||
if (trackpoint.coordinates().isValid()) {
|
if ((event.id == 42 || event.id == 43) && event.type == 3) {
|
||||||
trackpoint.setTimestamp(QDateTime::fromTime_t(timestamp
|
quint32 front = ((event.data & 0xFF000000) >> 24);
|
||||||
|
quint32 rear = ((event.data & 0x0000FF00) >> 8);
|
||||||
|
ctx.ratio = ((qreal)front / (qreal)rear);
|
||||||
|
}
|
||||||
|
} else if (def->globalId == RECORD_MESSAGE) {
|
||||||
|
if (ctx.timestamp > ctx.lastWrite
|
||||||
|
&& ctx.trackpoint.coordinates().isValid()) {
|
||||||
|
ctx.trackpoint.setTimestamp(QDateTime::fromTime_t(ctx.timestamp
|
||||||
+ 631065600));
|
+ 631065600));
|
||||||
track.append(trackpoint);
|
ctx.trackpoint.setRatio(ctx.ratio);
|
||||||
} else {
|
ctx.track.append(ctx.trackpoint);
|
||||||
if (trackpoint.coordinates().isNull())
|
ctx.trackpoint = Trackpoint();
|
||||||
warning("Missing coordinates");
|
ctx.lastWrite = ctx.timestamp;
|
||||||
else {
|
|
||||||
_errorString = "Invalid coordinates";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseDataMessage(TrackData &track, quint8 header)
|
bool FITParser::parseDataMessage(CTX &ctx, quint8 header)
|
||||||
{
|
{
|
||||||
int local_id = header & 0xf;
|
int local_id = header & 0xf;
|
||||||
MessageDefinition* def = &_defs[local_id];
|
MessageDefinition *def = &(ctx.defs[local_id]);
|
||||||
return parseData(track, def, 0);
|
return parseData(ctx, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseCompressedMessage(TrackData &track, quint8 header)
|
bool FITParser::parseCompressedMessage(CTX &ctx, quint8 header)
|
||||||
{
|
{
|
||||||
int local_id = (header >> 5) & 3;
|
int local_id = (header >> 5) & 3;
|
||||||
MessageDefinition* def = &_defs[local_id];
|
MessageDefinition *def = &(ctx.defs[local_id]);
|
||||||
return parseData(track, def, header & 0x1f);
|
ctx.timestamp += header & 0x1f;
|
||||||
|
return parseData(ctx, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseRecord(TrackData &track)
|
bool FITParser::parseRecord(CTX &ctx)
|
||||||
{
|
{
|
||||||
quint8 header;
|
quint8 header;
|
||||||
|
|
||||||
if (!readValue(header))
|
if (!readValue(ctx, header))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (header & 0x80)
|
if (header & 0x80)
|
||||||
return parseCompressedMessage(track, header);
|
return parseCompressedMessage(ctx, header);
|
||||||
else if (header & 0x40)
|
else if (header & 0x40)
|
||||||
return parseDefinitionMessage(header);
|
return parseDefinitionMessage(ctx, header);
|
||||||
else
|
else
|
||||||
return parseDataMessage(track, header);
|
return parseDataMessage(ctx, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseHeader()
|
bool FITParser::parseHeader(CTX &ctx)
|
||||||
{
|
{
|
||||||
FileHeader hdr;
|
FileHeader hdr;
|
||||||
quint16 crc;
|
quint16 crc;
|
||||||
qint64 len;
|
qint64 len;
|
||||||
|
|
||||||
STATIC_ASSERT(sizeof(hdr) == 12);
|
STATIC_ASSERT(sizeof(hdr) == 12);
|
||||||
len = _device->read((char*)&hdr, sizeof(hdr));
|
len = ctx.file->read((char*)&hdr, sizeof(hdr));
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
_errorString = "I/O error";
|
_errorString = "I/O error";
|
||||||
return false;
|
return false;
|
||||||
} else if ((size_t)len < sizeof(hdr)
|
} else if ((size_t)len < sizeof(hdr)
|
||||||
|| hdr.magic != qToLittleEndian(FIT_MAGIC)) {
|
|| hdr.magic != qToLittleEndian((quint32)FIT_MAGIC)) {
|
||||||
_errorString = "Not a FIT file";
|
_errorString = "Not a FIT file";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_len = qFromLittleEndian(hdr.dataSize);
|
ctx.len = qFromLittleEndian(hdr.dataSize);
|
||||||
|
|
||||||
if (hdr.headerSize > sizeof(hdr))
|
if (hdr.headerSize > sizeof(hdr))
|
||||||
if (!readData((char *)&crc, sizeof(crc)))
|
if (!readData(ctx.file, (char *)&crc, sizeof(crc)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -342,23 +376,17 @@ bool FITParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
Q_UNUSED(waypoints);
|
Q_UNUSED(waypoints);
|
||||||
bool ret = true;
|
CTX ctx(file);
|
||||||
|
|
||||||
_device = file;
|
|
||||||
_endian = 0;
|
|
||||||
_timestamp = 0;
|
|
||||||
|
|
||||||
if (!parseHeader())
|
if (!parseHeader(ctx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
tracks.append(TrackData());
|
while (ctx.len)
|
||||||
TrackData &track = tracks.last();
|
if (!parseRecord(ctx))
|
||||||
|
return false;
|
||||||
|
|
||||||
while (_len)
|
tracks.append(ctx.track);
|
||||||
if ((ret = parseRecord(track)) == false)
|
|
||||||
break;
|
|
||||||
|
|
||||||
clearDefinitions();
|
return true;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
@ -3,63 +3,34 @@
|
|||||||
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
|
class QFile;
|
||||||
|
|
||||||
class FITParser : public Parser
|
class FITParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FITParser();
|
|
||||||
|
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<Waypoint> &waypoints);
|
QList<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return 0;}
|
int errorLine() const {return 0;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct FileHeader {
|
struct Field;
|
||||||
quint8 headerSize;
|
class MessageDefinition;
|
||||||
quint8 protocolVersion;
|
class CTX;
|
||||||
quint16 profileVersion;
|
|
||||||
quint32 dataSize;
|
|
||||||
quint32 magic;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Field {
|
bool readData(QFile *file, char *data, size_t size);
|
||||||
quint8 id;
|
template<class T> bool readValue(CTX &ctx, T &val);
|
||||||
quint8 size;
|
bool skipValue(CTX &ctx, size_t size);
|
||||||
quint8 type;
|
bool readField(CTX &ctx, Field *field, quint32 &val);
|
||||||
};
|
|
||||||
|
|
||||||
struct MessageDefinition {
|
bool parseHeader(CTX &ctx);
|
||||||
quint8 endian;
|
bool parseRecord(CTX &ctx);
|
||||||
quint16 globalId;
|
bool parseDefinitionMessage(CTX &ctx, quint8 header);
|
||||||
quint8 numFields;
|
bool parseCompressedMessage(CTX &ctx, quint8 header);
|
||||||
Field *fields;
|
bool parseDataMessage(CTX &ctx, quint8 header);
|
||||||
quint8 numDevFields;
|
bool parseData(CTX &ctx, const MessageDefinition *def);
|
||||||
Field *devFields;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void warning(const char *text) const;
|
|
||||||
void clearDefinitions();
|
|
||||||
|
|
||||||
bool readData(char *data, size_t size);
|
|
||||||
template<class T> bool readValue(T &val);
|
|
||||||
bool skipValue(size_t size);
|
|
||||||
|
|
||||||
bool parseHeader();
|
|
||||||
bool parseRecord(TrackData &track);
|
|
||||||
bool parseDefinitionMessage(quint8 header);
|
|
||||||
bool parseCompressedMessage(TrackData &track, quint8 header);
|
|
||||||
bool parseDataMessage(TrackData &track, quint8 header);
|
|
||||||
bool parseData(TrackData &track, MessageDefinition *def, quint8 offset);
|
|
||||||
bool readField(Field *f, quint32 &val);
|
|
||||||
|
|
||||||
QIODevice *_device;
|
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
|
||||||
quint32 _len;
|
|
||||||
quint8 _endian;
|
|
||||||
quint32 _timestamp;
|
|
||||||
MessageDefinition _defs[16];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FITPARSER_H
|
#endif // FITPARSER_H
|
||||||
|
@ -51,6 +51,15 @@ Coordinates GPXParser::coordinates()
|
|||||||
return Coordinates(lon, lat);
|
return Coordinates(lon, lat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GPXParser::rpExtension(TrackData *autoRoute)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "rpt")
|
||||||
|
autoRoute->append(Trackpoint(coordinates()));
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GPXParser::tpExtension(Trackpoint &trackpoint)
|
void GPXParser::tpExtension(Trackpoint &trackpoint)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
@ -63,7 +72,17 @@ void GPXParser::tpExtension(Trackpoint &trackpoint)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::extensions(Trackpoint &trackpoint)
|
void GPXParser::rteptExtensions(TrackData *autoRoute)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "RoutePointExtension")
|
||||||
|
rpExtension(autoRoute);
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPXParser::trkptExtensions(Trackpoint &trackpoint)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "speed")
|
if (_reader.name() == "speed")
|
||||||
@ -95,7 +114,7 @@ void GPXParser::trackpointData(Trackpoint &trackpoint)
|
|||||||
else if (_reader.name() == "geoidheight")
|
else if (_reader.name() == "geoidheight")
|
||||||
gh = number();
|
gh = number();
|
||||||
else if (_reader.name() == "extensions")
|
else if (_reader.name() == "extensions")
|
||||||
extensions(trackpoint);
|
trkptExtensions(trackpoint);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
@ -104,7 +123,7 @@ void GPXParser::trackpointData(Trackpoint &trackpoint)
|
|||||||
trackpoint.setElevation(trackpoint.elevation() - gh);
|
trackpoint.setElevation(trackpoint.elevation() - gh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::waypointData(Waypoint &waypoint)
|
void GPXParser::waypointData(Waypoint &waypoint, TrackData *autoRoute)
|
||||||
{
|
{
|
||||||
qreal gh = NAN;
|
qreal gh = NAN;
|
||||||
|
|
||||||
@ -119,6 +138,8 @@ void GPXParser::waypointData(Waypoint &waypoint)
|
|||||||
gh = number();
|
gh = number();
|
||||||
else if (_reader.name() == "time")
|
else if (_reader.name() == "time")
|
||||||
waypoint.setTimestamp(time());
|
waypoint.setTimestamp(time());
|
||||||
|
else if (autoRoute && _reader.name() == "extensions")
|
||||||
|
rteptExtensions(autoRoute);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
@ -138,12 +159,14 @@ void GPXParser::trackpoints(TrackData &track)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::routepoints(RouteData &route)
|
void GPXParser::routepoints(RouteData &route, QList<TrackData> &tracks)
|
||||||
{
|
{
|
||||||
|
TrackData autoRoute;
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "rtept") {
|
if (_reader.name() == "rtept") {
|
||||||
route.append(Waypoint(coordinates()));
|
route.append(Waypoint(coordinates()));
|
||||||
waypointData(route.last());
|
waypointData(route.last(), &autoRoute);
|
||||||
} else if (_reader.name() == "name")
|
} else if (_reader.name() == "name")
|
||||||
route.setName(_reader.readElementText());
|
route.setName(_reader.readElementText());
|
||||||
else if (_reader.name() == "desc")
|
else if (_reader.name() == "desc")
|
||||||
@ -151,6 +174,12 @@ void GPXParser::routepoints(RouteData &route)
|
|||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!autoRoute.isEmpty()) {
|
||||||
|
autoRoute.setName(route.name());
|
||||||
|
autoRoute.setDescription(route.description());
|
||||||
|
tracks.append(autoRoute);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::track(TrackData &track)
|
void GPXParser::track(TrackData &track)
|
||||||
@ -176,7 +205,7 @@ void GPXParser::gpx(QList<TrackData> &tracks, QList<RouteData> &routes,
|
|||||||
track(tracks.back());
|
track(tracks.back());
|
||||||
} else if (_reader.name() == "rte") {
|
} else if (_reader.name() == "rte") {
|
||||||
routes.append(RouteData());
|
routes.append(RouteData());
|
||||||
routepoints(routes.back());
|
routepoints(routes.back(), tracks);
|
||||||
} else if (_reader.name() == "wpt") {
|
} else if (_reader.name() == "wpt") {
|
||||||
waypoints.append(Waypoint(coordinates()));
|
waypoints.append(Waypoint(coordinates()));
|
||||||
waypointData(waypoints.last());
|
waypointData(waypoints.last());
|
||||||
|
@ -18,11 +18,13 @@ private:
|
|||||||
QList<Waypoint> &waypoints);
|
QList<Waypoint> &waypoints);
|
||||||
void track(TrackData &track);
|
void track(TrackData &track);
|
||||||
void trackpoints(TrackData &track);
|
void trackpoints(TrackData &track);
|
||||||
void routepoints(RouteData &route);
|
void routepoints(RouteData &route, QList<TrackData> &tracks);
|
||||||
|
void rpExtension(TrackData *autoRoute);
|
||||||
void tpExtension(Trackpoint &trackpoint);
|
void tpExtension(Trackpoint &trackpoint);
|
||||||
void extensions(Trackpoint &trackpoint);
|
void trkptExtensions(Trackpoint &trackpoint);
|
||||||
|
void rteptExtensions(TrackData *autoRoute);
|
||||||
void trackpointData(Trackpoint &trackpoint);
|
void trackpointData(Trackpoint &trackpoint);
|
||||||
void waypointData(Waypoint &waypoint);
|
void waypointData(Waypoint &waypoint, TrackData *autoRoute = 0);
|
||||||
qreal number();
|
qreal number();
|
||||||
QDateTime time();
|
QDateTime time();
|
||||||
Coordinates coordinates();
|
Coordinates coordinates();
|
||||||
|
@ -24,7 +24,8 @@ bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
QByteArray line = file->readLine();
|
QByteArray line = file->readLine();
|
||||||
|
|
||||||
if (_errorLine == 1) {
|
if (_errorLine == 1) {
|
||||||
if (!line.trimmed().startsWith("OziExplorer Track Point File")) {
|
QString fileType(QString::fromUtf8(line).trimmed());
|
||||||
|
if (!fileType.startsWith("OziExplorer Track Point File")) {
|
||||||
_errorString = "Not a PLT file";
|
_errorString = "Not a PLT file";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -107,7 +108,8 @@ bool RTEParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
QByteArray line = file->readLine();
|
QByteArray line = file->readLine();
|
||||||
|
|
||||||
if (_errorLine == 1) {
|
if (_errorLine == 1) {
|
||||||
if (!line.trimmed().startsWith("OziExplorer Route File")) {
|
QString fileType(QString::fromUtf8(line).trimmed());
|
||||||
|
if (!fileType.startsWith("OziExplorer Route File")) {
|
||||||
_errorString = "Not a RTE file";
|
_errorString = "Not a RTE file";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -201,7 +203,8 @@ bool WPTParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
QByteArray line = file->readLine();
|
QByteArray line = file->readLine();
|
||||||
|
|
||||||
if (_errorLine == 1) {
|
if (_errorLine == 1) {
|
||||||
if (!line.trimmed().startsWith("OziExplorer Waypoint File")) {
|
QString fileType(QString::fromUtf8(line).trimmed());
|
||||||
|
if (!fileType.startsWith("OziExplorer Waypoint File")) {
|
||||||
_errorString = "Not a WPT file";
|
_errorString = "Not a WPT file";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "rtree.h"
|
#include "common/rtree.h"
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include "track.h"
|
#include "track.h"
|
||||||
|
|
||||||
#define OUTLIER_WINDOW 21
|
|
||||||
|
|
||||||
int Track::_elevationWindow = 3;
|
int Track::_elevationWindow = 3;
|
||||||
int Track::_speedWindow = 5;
|
int Track::_speedWindow = 5;
|
||||||
int Track::_heartRateWindow = 3;
|
int Track::_heartRateWindow = 3;
|
||||||
@ -12,15 +10,16 @@ qreal Track::_pauseSpeed = 0.5;
|
|||||||
int Track::_pauseInterval = 10;
|
int Track::_pauseInterval = 10;
|
||||||
|
|
||||||
bool Track::_outlierEliminate = true;
|
bool Track::_outlierEliminate = true;
|
||||||
|
bool Track::_useReportedSpeed = false;
|
||||||
|
|
||||||
|
|
||||||
static qreal median(QVector<qreal> v)
|
static qreal median(QVector<qreal> &v)
|
||||||
{
|
{
|
||||||
qSort(v.begin(), v.end());
|
qSort(v.begin(), v.end());
|
||||||
return v.at(v.size() / 2);
|
return v.at(v.size() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal MAD(QVector<qreal> v, qreal m)
|
static qreal MAD(QVector<qreal> &v, qreal m)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < v.size(); i++)
|
for (int i = 0; i < v.size(); i++)
|
||||||
v[i] = qAbs(v.at(i) - m);
|
v[i] = qAbs(v.at(i) - m);
|
||||||
@ -28,21 +27,17 @@ static qreal MAD(QVector<qreal> v, qreal m)
|
|||||||
return v.at(v.size() / 2);
|
return v.at(v.size() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QSet<int> eliminate(const QVector<qreal> &v, int window)
|
static QSet<int> eliminate(const QVector<qreal> &v)
|
||||||
{
|
{
|
||||||
QSet<int> rm;
|
QSet<int> rm;
|
||||||
qreal m, M;
|
|
||||||
|
|
||||||
|
QVector<qreal> w(v);
|
||||||
|
qreal m = median(w);
|
||||||
|
qreal M = MAD(w, m);
|
||||||
|
|
||||||
if (v.size() < window)
|
for (int i = 0; i < v.size(); i++)
|
||||||
return rm;
|
if (qAbs((0.6745 * (v.at(i) - m)) / M) > 5)
|
||||||
|
|
||||||
for (int i = window/2; i < v.size() - window/2; i++) {
|
|
||||||
m = median(v.mid(i - window/2, window));
|
|
||||||
M = MAD(v.mid(i - window/2, window), m);
|
|
||||||
if (qAbs((0.6745 * (v.at(i) - m)) / M) > 3.5)
|
|
||||||
rm.insert(i);
|
rm.insert(i);
|
||||||
}
|
|
||||||
|
|
||||||
return rm;
|
return rm;
|
||||||
}
|
}
|
||||||
@ -74,37 +69,33 @@ static Graph filter(const Graph &g, int window)
|
|||||||
|
|
||||||
Track::Track(const TrackData &data) : _data(data)
|
Track::Track(const TrackData &data) : _data(data)
|
||||||
{
|
{
|
||||||
qreal dt, ds, total;
|
QVector<qreal> acceleration;
|
||||||
int last;
|
qreal ds, dt;
|
||||||
|
|
||||||
|
|
||||||
_time.append(0);
|
_time.append(0);
|
||||||
_distance.append(0);
|
_distance.append(0);
|
||||||
_speed.append(0);
|
_speed.append(0);
|
||||||
|
acceleration.append(0);
|
||||||
last = 0;
|
|
||||||
|
|
||||||
for (int i = 1; i < _data.count(); i++) {
|
for (int i = 1; i < _data.count(); i++) {
|
||||||
ds = _data.at(i).coordinates().distanceTo(_data.at(i-1).coordinates());
|
ds = _data.at(i).coordinates().distanceTo(_data.at(i-1).coordinates());
|
||||||
_distance.append(ds);
|
_distance.append(_distance.at(i-1) + ds);
|
||||||
|
|
||||||
if (_data.first().hasTimestamp() && _data.at(i).hasTimestamp()
|
if (_data.first().hasTimestamp() && _data.at(i).hasTimestamp()
|
||||||
&& _data.at(i).timestamp() > _data.at(last).timestamp()) {
|
&& _data.at(i).timestamp() >= _data.at(i-1).timestamp())
|
||||||
_time.append(_data.first().timestamp().msecsTo(
|
_time.append(_data.first().timestamp().msecsTo(
|
||||||
_data.at(i).timestamp()) / 1000.0);
|
_data.at(i).timestamp()) / 1000.0);
|
||||||
last = i;
|
else
|
||||||
} else
|
|
||||||
_time.append(NAN);
|
_time.append(NAN);
|
||||||
|
|
||||||
if (std::isnan(_time.at(i)) || std::isnan(_time.at(i-1)))
|
dt = _time.at(i) - _time.at(i-1);
|
||||||
_speed.append(NAN);
|
if (dt < 1e-3) {
|
||||||
else {
|
_speed.append(_speed.at(i-1));
|
||||||
dt = _time.at(i) - _time.at(i-1);
|
acceleration.append(acceleration.at(i-1));
|
||||||
if (dt < 1e-3) {
|
} else {
|
||||||
_speed.append(_speed.at(i-1));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
_speed.append(ds / dt);
|
_speed.append(ds / dt);
|
||||||
|
qreal dv = _speed.at(i) - _speed.at(i-1);
|
||||||
|
acceleration.append(dv / dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,20 +109,37 @@ Track::Track(const TrackData &data) : _data(data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_outlierEliminate)
|
if (!_outlierEliminate)
|
||||||
_outliers = eliminate(_speed, OUTLIER_WINDOW);
|
return;
|
||||||
|
|
||||||
|
_outliers = eliminate(acceleration);
|
||||||
|
|
||||||
QSet<int>::const_iterator it;
|
QSet<int>::const_iterator it;
|
||||||
for (it = _stop.constBegin(); it != _stop.constEnd(); ++it)
|
for (it = _stop.constBegin(); it != _stop.constEnd(); ++it)
|
||||||
_outliers.remove(*it);
|
_outliers.remove(*it);
|
||||||
|
|
||||||
total = 0;
|
int last = 0;
|
||||||
for (int i = 0; i < _data.size(); i++) {
|
for (int i = 0; i < _data.size(); i++) {
|
||||||
|
if (_outliers.contains(i))
|
||||||
|
last++;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (int i = last + 1; i < _data.size(); i++) {
|
||||||
if (_outliers.contains(i))
|
if (_outliers.contains(i))
|
||||||
continue;
|
continue;
|
||||||
if (!discardStopPoint(i))
|
if (discardStopPoint(i)) {
|
||||||
total += _distance.at(i);
|
_distance[i] = _distance.at(last);
|
||||||
_distance[i] = total;
|
_speed[i] = 0;
|
||||||
|
} else {
|
||||||
|
ds = _data.at(i).coordinates().distanceTo(
|
||||||
|
_data.at(last).coordinates());
|
||||||
|
_distance[i] = _distance.at(last) + ds;
|
||||||
|
|
||||||
|
dt = _time.at(i) - _time.at(last);
|
||||||
|
_speed[i] = (dt < 1e-3) ? _speed.at(last) : ds / dt;
|
||||||
|
}
|
||||||
|
last = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,14 +159,15 @@ Graph Track::speed() const
|
|||||||
{
|
{
|
||||||
Graph raw, filtered;
|
Graph raw, filtered;
|
||||||
qreal v;
|
qreal v;
|
||||||
QSet<int> stop;
|
QList<int> stop;
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++) {
|
for (int i = 0; i < _data.size(); i++) {
|
||||||
if (_stop.contains(i) && (!std::isnan(_speed.at(i))
|
if (_stop.contains(i) && (!std::isnan(_speed.at(i))
|
||||||
|| _data.at(i).hasSpeed())) {
|
|| _data.at(i).hasSpeed())) {
|
||||||
v = 0;
|
v = 0;
|
||||||
stop.insert(raw.size());
|
stop.append(raw.size());
|
||||||
} else if (_data.at(i).hasSpeed() && !_outliers.contains(i))
|
} else if (_useReportedSpeed && _data.at(i).hasSpeed()
|
||||||
|
&& !_outliers.contains(i))
|
||||||
v = _data.at(i).speed();
|
v = _data.at(i).speed();
|
||||||
else if (!std::isnan(_speed.at(i)) && !_outliers.contains(i))
|
else if (!std::isnan(_speed.at(i)) && !_outliers.contains(i))
|
||||||
v = _speed.at(i);
|
v = _speed.at(i);
|
||||||
@ -170,9 +179,8 @@ Graph Track::speed() const
|
|||||||
|
|
||||||
filtered = filter(raw, _speedWindow);
|
filtered = filter(raw, _speedWindow);
|
||||||
|
|
||||||
QSet<int>::const_iterator it;
|
for (int i = 0; i < stop.size(); i++)
|
||||||
for (it = stop.constBegin(); it != stop.constEnd(); ++it)
|
filtered[stop.at(i)].setY(0);
|
||||||
filtered[*it].setY(0);
|
|
||||||
|
|
||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
@ -201,16 +209,28 @@ Graph Track::temperature() const
|
|||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Graph Track::ratio() const
|
||||||
|
{
|
||||||
|
Graph raw;
|
||||||
|
|
||||||
|
for (int i = 0; i < _data.size(); i++)
|
||||||
|
if (_data.at(i).hasRatio() && !_outliers.contains(i))
|
||||||
|
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||||
|
_data.at(i).ratio()));
|
||||||
|
|
||||||
|
return raw;
|
||||||
|
}
|
||||||
|
|
||||||
Graph Track::cadence() const
|
Graph Track::cadence() const
|
||||||
{
|
{
|
||||||
Graph raw, filtered;
|
Graph raw, filtered;
|
||||||
QSet<int> stop;
|
QList<int> stop;
|
||||||
qreal c;
|
qreal c;
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++) {
|
for (int i = 0; i < _data.size(); i++) {
|
||||||
if (_data.at(i).hasCadence() && _stop.contains(i)) {
|
if (_data.at(i).hasCadence() && _stop.contains(i)) {
|
||||||
c = 0;
|
c = 0;
|
||||||
stop.insert(raw.size());
|
stop.append(raw.size());
|
||||||
} else if (_data.at(i).hasCadence() && !_outliers.contains(i))
|
} else if (_data.at(i).hasCadence() && !_outliers.contains(i))
|
||||||
c = _data.at(i).cadence();
|
c = _data.at(i).cadence();
|
||||||
else
|
else
|
||||||
@ -221,9 +241,8 @@ Graph Track::cadence() const
|
|||||||
|
|
||||||
filtered = filter(raw, _cadenceWindow);
|
filtered = filter(raw, _cadenceWindow);
|
||||||
|
|
||||||
QSet<int>::const_iterator it;
|
for (int i = 0; i < stop.size(); i++)
|
||||||
for (it = stop.constBegin(); it != stop.constEnd(); ++it)
|
filtered[stop.at(i)].setY(0);
|
||||||
filtered[*it].setY(0);
|
|
||||||
|
|
||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
@ -231,13 +250,13 @@ Graph Track::cadence() const
|
|||||||
Graph Track::power() const
|
Graph Track::power() const
|
||||||
{
|
{
|
||||||
Graph raw, filtered;
|
Graph raw, filtered;
|
||||||
QSet<int> stop;
|
QList<int> stop;
|
||||||
qreal p;
|
qreal p;
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++) {
|
for (int i = 0; i < _data.size(); i++) {
|
||||||
if (_data.at(i).hasPower() && _stop.contains(i)) {
|
if (_data.at(i).hasPower() && _stop.contains(i)) {
|
||||||
p = 0;
|
p = 0;
|
||||||
stop.insert(raw.size());
|
stop.append(raw.size());
|
||||||
} else if (_data.at(i).hasPower() && !_outliers.contains(i))
|
} else if (_data.at(i).hasPower() && !_outliers.contains(i))
|
||||||
p = _data.at(i).power();
|
p = _data.at(i).power();
|
||||||
else
|
else
|
||||||
@ -248,22 +267,29 @@ Graph Track::power() const
|
|||||||
|
|
||||||
filtered = filter(raw, _powerWindow);
|
filtered = filter(raw, _powerWindow);
|
||||||
|
|
||||||
QSet<int>::const_iterator it;
|
for (int i = 0; i < stop.size(); i++)
|
||||||
for (it = stop.constBegin(); it != stop.constEnd(); ++it)
|
filtered[stop.at(i)].setY(0);
|
||||||
filtered[*it].setY(0);
|
|
||||||
|
|
||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal Track::distance() const
|
qreal Track::distance() const
|
||||||
{
|
{
|
||||||
return _distance.isEmpty() ? 0 : _distance.last();
|
for (int i = _distance.size() - 1; i >= 0; i--)
|
||||||
|
if (!_outliers.contains(i))
|
||||||
|
return _distance.at(i);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal Track::time() const
|
qreal Track::time() const
|
||||||
{
|
{
|
||||||
return (_data.size() < 2) ? 0 :
|
for (int i = _data.size() - 1; i >= 0; i--)
|
||||||
(_data.first().timestamp().msecsTo(_data.last().timestamp()) / 1000.0);
|
if (!_outliers.contains(i))
|
||||||
|
return _data.first().timestamp().msecsTo(_data.at(i).timestamp())
|
||||||
|
/ 1000.0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal Track::movingTime() const
|
qreal Track::movingTime() const
|
||||||
|
@ -22,6 +22,7 @@ public:
|
|||||||
Graph temperature() const;
|
Graph temperature() const;
|
||||||
Graph cadence() const;
|
Graph cadence() const;
|
||||||
Graph power() const;
|
Graph power() const;
|
||||||
|
Graph ratio() const;
|
||||||
|
|
||||||
qreal distance() const;
|
qreal distance() const;
|
||||||
qreal time() const;
|
qreal time() const;
|
||||||
@ -42,6 +43,7 @@ public:
|
|||||||
static void setPauseInterval(int interval) {_pauseInterval = interval;}
|
static void setPauseInterval(int interval) {_pauseInterval = interval;}
|
||||||
static void setOutlierElimination(bool eliminate)
|
static void setOutlierElimination(bool eliminate)
|
||||||
{_outlierEliminate = eliminate;}
|
{_outlierEliminate = eliminate;}
|
||||||
|
static void useReportedSpeed(bool use) {_useReportedSpeed = use;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool discardStopPoint(int i) const;
|
bool discardStopPoint(int i) const;
|
||||||
@ -58,15 +60,14 @@ private:
|
|||||||
qreal _pause;
|
qreal _pause;
|
||||||
|
|
||||||
static bool _outlierEliminate;
|
static bool _outlierEliminate;
|
||||||
|
|
||||||
static int _elevationWindow;
|
static int _elevationWindow;
|
||||||
static int _speedWindow;
|
static int _speedWindow;
|
||||||
static int _heartRateWindow;
|
static int _heartRateWindow;
|
||||||
static int _cadenceWindow;
|
static int _cadenceWindow;
|
||||||
static int _powerWindow;
|
static int _powerWindow;
|
||||||
|
|
||||||
static qreal _pauseSpeed;
|
static qreal _pauseSpeed;
|
||||||
static int _pauseInterval;
|
static int _pauseInterval;
|
||||||
|
static bool _useReportedSpeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACK_H
|
#endif // TRACK_H
|
||||||
|
@ -11,10 +11,10 @@ class Trackpoint
|
|||||||
public:
|
public:
|
||||||
Trackpoint()
|
Trackpoint()
|
||||||
{_elevation = NAN; _speed = NAN; _heartRate = NAN; _temperature = NAN;
|
{_elevation = NAN; _speed = NAN; _heartRate = NAN; _temperature = NAN;
|
||||||
_cadence = NAN; _power = NAN;}
|
_cadence = NAN; _power = NAN; _ratio = NAN;}
|
||||||
Trackpoint(const Coordinates &coordinates) : _coordinates(coordinates)
|
Trackpoint(const Coordinates &coordinates) : _coordinates(coordinates)
|
||||||
{_elevation = NAN; _speed = NAN; _heartRate = NAN; _temperature = NAN;
|
{_elevation = NAN; _speed = NAN; _heartRate = NAN; _temperature = NAN;
|
||||||
_cadence = NAN; _power = NAN;}
|
_cadence = NAN; _power = NAN; _ratio = NAN;}
|
||||||
|
|
||||||
const Coordinates &coordinates() const {return _coordinates;}
|
const Coordinates &coordinates() const {return _coordinates;}
|
||||||
Coordinates &rcoordinates() {return _coordinates;}
|
Coordinates &rcoordinates() {return _coordinates;}
|
||||||
@ -25,6 +25,7 @@ public:
|
|||||||
qreal temperature() const {return _temperature;}
|
qreal temperature() const {return _temperature;}
|
||||||
qreal cadence() const {return _cadence;}
|
qreal cadence() const {return _cadence;}
|
||||||
qreal power() const {return _power;}
|
qreal power() const {return _power;}
|
||||||
|
qreal ratio() const {return _ratio;}
|
||||||
|
|
||||||
void setCoordinates(const Coordinates &coordinates)
|
void setCoordinates(const Coordinates &coordinates)
|
||||||
{_coordinates = coordinates;}
|
{_coordinates = coordinates;}
|
||||||
@ -35,6 +36,7 @@ public:
|
|||||||
void setTemperature(qreal temperature) {_temperature = temperature;}
|
void setTemperature(qreal temperature) {_temperature = temperature;}
|
||||||
void setCadence(qreal cadence) {_cadence = cadence;}
|
void setCadence(qreal cadence) {_cadence = cadence;}
|
||||||
void setPower(qreal power) {_power = power;}
|
void setPower(qreal power) {_power = power;}
|
||||||
|
void setRatio(qreal ratio) {_ratio = ratio;}
|
||||||
|
|
||||||
bool hasTimestamp() const {return !_timestamp.isNull();}
|
bool hasTimestamp() const {return !_timestamp.isNull();}
|
||||||
bool hasElevation() const {return !std::isnan(_elevation);}
|
bool hasElevation() const {return !std::isnan(_elevation);}
|
||||||
@ -43,6 +45,7 @@ public:
|
|||||||
bool hasTemperature() const {return !std::isnan(_temperature);}
|
bool hasTemperature() const {return !std::isnan(_temperature);}
|
||||||
bool hasCadence() const {return !std::isnan(_cadence);}
|
bool hasCadence() const {return !std::isnan(_cadence);}
|
||||||
bool hasPower() const {return !std::isnan(_power);}
|
bool hasPower() const {return !std::isnan(_power);}
|
||||||
|
bool hasRatio() const {return !std::isnan(_ratio);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Coordinates _coordinates;
|
Coordinates _coordinates;
|
||||||
@ -53,6 +56,7 @@ private:
|
|||||||
qreal _temperature;
|
qreal _temperature;
|
||||||
qreal _cadence;
|
qreal _cadence;
|
||||||
qreal _power;
|
qreal _power;
|
||||||
|
qreal _ratio;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_TYPEINFO(Trackpoint, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(Trackpoint, Q_MOVABLE_TYPE);
|
||||||
@ -63,7 +67,8 @@ inline QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint)
|
|||||||
dbg.nospace() << "Trackpoint(" << trackpoint.coordinates() << ", "
|
dbg.nospace() << "Trackpoint(" << trackpoint.coordinates() << ", "
|
||||||
<< trackpoint.timestamp() << ", " << trackpoint.elevation() << ", "
|
<< trackpoint.timestamp() << ", " << trackpoint.elevation() << ", "
|
||||||
<< trackpoint.speed() << ", " << trackpoint.heartRate() << ", "
|
<< trackpoint.speed() << ", " << trackpoint.heartRate() << ", "
|
||||||
<< trackpoint.temperature() << ")";
|
<< trackpoint.temperature() << ", " << trackpoint.cadence() << ", "
|
||||||
|
<< trackpoint.power() << ", " << trackpoint.ratio() << ")";
|
||||||
return dbg.space();
|
return dbg.space();
|
||||||
}
|
}
|
||||||
#endif // QT_NO_DEBUG
|
#endif // QT_NO_DEBUG
|
||||||
|
@ -45,16 +45,12 @@ Defense.
|
|||||||
#include "albersequal.h"
|
#include "albersequal.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef M_PI_2
|
|
||||||
#define M_PI_2 1.57079632679489661923
|
|
||||||
#endif // M_PI_2
|
|
||||||
|
|
||||||
#define ONE_MINUS_SQR(x) (1.0 - (x) * (x))
|
#define ONE_MINUS_SQR(x) (1.0 - (x) * (x))
|
||||||
#define ALBERS_Q(slat, one_minus_sqr_es_sin, es_sin) \
|
#define ALBERS_Q(slat, one_minus_sqr_e_sin, es_sin) \
|
||||||
(_one_minus_es2 * ((slat) / (one_minus_sqr_es_sin) - \
|
(_one_minus_es * ((slat) / (one_minus_sqr_e_sin) - \
|
||||||
(1 / (_two_es)) * log((1 - (es_sin)) / (1 + (es_sin)))))
|
(1 / (_two_e)) * log((1 - (es_sin)) / (1 + (es_sin)))))
|
||||||
#define ALBERS_M(clat, one_minus_sqr_es_sin) \
|
#define ALBERS_M(clat, one_minus_sqr_e_sin) \
|
||||||
((clat) / sqrt(one_minus_sqr_es_sin))
|
((clat) / sqrt(one_minus_sqr_e_sin))
|
||||||
|
|
||||||
|
|
||||||
AlbersEqual::AlbersEqual(const Ellipsoid *ellipsoid, double standardParallel1,
|
AlbersEqual::AlbersEqual(const Ellipsoid *ellipsoid, double standardParallel1,
|
||||||
@ -64,8 +60,8 @@ AlbersEqual::AlbersEqual(const Ellipsoid *ellipsoid, double standardParallel1,
|
|||||||
double sin_lat, sin_lat1, sin_lat2, cos_lat1, cos_lat2;
|
double sin_lat, sin_lat1, sin_lat2, cos_lat1, cos_lat2;
|
||||||
double m1, m2, sqr_m1, sqr_m2;
|
double m1, m2, sqr_m1, sqr_m2;
|
||||||
double q0, q1, q2;
|
double q0, q1, q2;
|
||||||
double es_sin, es_sin1, es_sin2;
|
double e_sin, e_sin1, e_sin2;
|
||||||
double one_minus_sqr_es_sin1, one_minus_sqr_es_sin2;
|
double one_minus_sqr_e_sin1, one_minus_sqr_e_sin2;
|
||||||
double nq0;
|
double nq0;
|
||||||
double sp1, sp2;
|
double sp1, sp2;
|
||||||
|
|
||||||
@ -79,31 +75,30 @@ AlbersEqual::AlbersEqual(const Ellipsoid *ellipsoid, double standardParallel1,
|
|||||||
sp2 = deg2rad(standardParallel2);
|
sp2 = deg2rad(standardParallel2);
|
||||||
|
|
||||||
_a2 = ellipsoid->radius() * ellipsoid->radius();
|
_a2 = ellipsoid->radius() * ellipsoid->radius();
|
||||||
_es2 = 2 * ellipsoid->flattening() - ellipsoid->flattening()
|
_es = ellipsoid->es();
|
||||||
* ellipsoid->flattening();
|
_e = sqrt(_es);
|
||||||
_es = sqrt(_es2);
|
_one_minus_es = 1 - _es;
|
||||||
_one_minus_es2 = 1 - _es2;
|
_two_e = 2 * _e;
|
||||||
_two_es = 2 * _es;
|
|
||||||
|
|
||||||
sin_lat = sin(_latitudeOrigin);
|
sin_lat = sin(_latitudeOrigin);
|
||||||
es_sin = _es * sin_lat;
|
e_sin = _e * sin_lat;
|
||||||
q0 = ALBERS_Q(sin_lat, ONE_MINUS_SQR(es_sin), es_sin);
|
q0 = ALBERS_Q(sin_lat, ONE_MINUS_SQR(e_sin), e_sin);
|
||||||
|
|
||||||
sin_lat1 = sin(sp1);
|
sin_lat1 = sin(sp1);
|
||||||
cos_lat1 = cos(sp1);
|
cos_lat1 = cos(sp1);
|
||||||
es_sin1 = _es * sin_lat1;
|
e_sin1 = _e * sin_lat1;
|
||||||
one_minus_sqr_es_sin1 = ONE_MINUS_SQR(es_sin1);
|
one_minus_sqr_e_sin1 = ONE_MINUS_SQR(e_sin1);
|
||||||
m1 = ALBERS_M(cos_lat1, one_minus_sqr_es_sin1);
|
m1 = ALBERS_M(cos_lat1, one_minus_sqr_e_sin1);
|
||||||
q1 = ALBERS_Q(sin_lat1, one_minus_sqr_es_sin1, es_sin1);
|
q1 = ALBERS_Q(sin_lat1, one_minus_sqr_e_sin1, e_sin1);
|
||||||
|
|
||||||
sqr_m1 = m1 * m1;
|
sqr_m1 = m1 * m1;
|
||||||
if (fabs(sp1 - sp2) > 1.0e-10) {
|
if (fabs(sp1 - sp2) > 1.0e-10) {
|
||||||
sin_lat2 = sin(sp2);
|
sin_lat2 = sin(sp2);
|
||||||
cos_lat2 = cos(sp2);
|
cos_lat2 = cos(sp2);
|
||||||
es_sin2 = _es * sin_lat2;
|
e_sin2 = _e * sin_lat2;
|
||||||
one_minus_sqr_es_sin2 = ONE_MINUS_SQR(es_sin2);
|
one_minus_sqr_e_sin2 = ONE_MINUS_SQR(e_sin2);
|
||||||
m2 = ALBERS_M(cos_lat2, one_minus_sqr_es_sin2);
|
m2 = ALBERS_M(cos_lat2, one_minus_sqr_e_sin2);
|
||||||
q2 = ALBERS_Q(sin_lat2, one_minus_sqr_es_sin2, es_sin2);
|
q2 = ALBERS_Q(sin_lat2, one_minus_sqr_e_sin2, e_sin2);
|
||||||
sqr_m2 = m2 * m2;
|
sqr_m2 = m2 * m2;
|
||||||
_n = (sqr_m1 - sqr_m2) / (q2 - q1);
|
_n = (sqr_m1 - sqr_m2) / (q2 - q1);
|
||||||
} else
|
} else
|
||||||
@ -119,7 +114,7 @@ PointD AlbersEqual::ll2xy(const Coordinates &c) const
|
|||||||
{
|
{
|
||||||
double dlam;
|
double dlam;
|
||||||
double sin_lat;
|
double sin_lat;
|
||||||
double es_sin;
|
double e_sin;
|
||||||
double q;
|
double q;
|
||||||
double rho;
|
double rho;
|
||||||
double theta;
|
double theta;
|
||||||
@ -128,13 +123,13 @@ PointD AlbersEqual::ll2xy(const Coordinates &c) const
|
|||||||
|
|
||||||
dlam = deg2rad(c.lon()) - _longitudeOrigin;
|
dlam = deg2rad(c.lon()) - _longitudeOrigin;
|
||||||
if (dlam > M_PI)
|
if (dlam > M_PI)
|
||||||
dlam -= 2.0 * M_PI;
|
dlam -= M_2_PI;
|
||||||
if (dlam < -M_PI)
|
if (dlam < -M_PI)
|
||||||
dlam += 2.0 * M_PI;
|
dlam += M_2_PI;
|
||||||
|
|
||||||
sin_lat = sin(deg2rad(c.lat()));
|
sin_lat = sin(deg2rad(c.lat()));
|
||||||
es_sin = _es * sin_lat;
|
e_sin = _e * sin_lat;
|
||||||
q = ALBERS_Q(sin_lat, ONE_MINUS_SQR(es_sin), es_sin);
|
q = ALBERS_Q(sin_lat, ONE_MINUS_SQR(e_sin), e_sin);
|
||||||
nq = _n * q;
|
nq = _n * q;
|
||||||
rho = (_C < nq) ? 0 : _a_over_n * sqrt(_C - nq);
|
rho = (_C < nq) ? 0 : _a_over_n * sqrt(_C - nq);
|
||||||
theta = _n * dlam;
|
theta = _n * dlam;
|
||||||
@ -151,7 +146,7 @@ Coordinates AlbersEqual::xy2ll(const PointD &p) const
|
|||||||
double rho, rho_n;
|
double rho, rho_n;
|
||||||
double phi, delta_phi = 1.0;
|
double phi, delta_phi = 1.0;
|
||||||
double sin_phi;
|
double sin_phi;
|
||||||
double es_sin, one_minus_sqr_es_sin;
|
double e_sin, one_minus_sqr_e_sin;
|
||||||
double theta = 0.0;
|
double theta = 0.0;
|
||||||
int count = 30;
|
int count = 30;
|
||||||
double tolerance = 4.85e-10;
|
double tolerance = 4.85e-10;
|
||||||
@ -174,7 +169,7 @@ Coordinates AlbersEqual::xy2ll(const PointD &p) const
|
|||||||
theta = atan2(dx, rho0_minus_dy);
|
theta = atan2(dx, rho0_minus_dy);
|
||||||
rho_n = rho * _n;
|
rho_n = rho * _n;
|
||||||
q = (_C - (rho_n * rho_n) / _a2) / _n;
|
q = (_C - (rho_n * rho_n) / _a2) / _n;
|
||||||
qc = 1 - ((_one_minus_es2) / (_two_es)) * log((1.0 - _es) / (1.0 + _es));
|
qc = 1 - ((_one_minus_es) / (_two_e)) * log((1.0 - _e) / (1.0 + _e));
|
||||||
if (fabs(fabs(qc) - fabs(q)) > 1.0e-6) {
|
if (fabs(fabs(qc) - fabs(q)) > 1.0e-6) {
|
||||||
q_over_2 = q / 2.0;
|
q_over_2 = q / 2.0;
|
||||||
if (q_over_2 > 1.0)
|
if (q_over_2 > 1.0)
|
||||||
@ -183,17 +178,17 @@ Coordinates AlbersEqual::xy2ll(const PointD &p) const
|
|||||||
lat = -M_PI_2;
|
lat = -M_PI_2;
|
||||||
else {
|
else {
|
||||||
phi = asin(q_over_2);
|
phi = asin(q_over_2);
|
||||||
if (_es < 1.0e-10)
|
if (_e < 1.0e-10)
|
||||||
lat = phi;
|
lat = phi;
|
||||||
else {
|
else {
|
||||||
while ((fabs(delta_phi) > tolerance) && count) {
|
while ((fabs(delta_phi) > tolerance) && count) {
|
||||||
sin_phi = sin(phi);
|
sin_phi = sin(phi);
|
||||||
es_sin = _es * sin_phi;
|
e_sin = _e * sin_phi;
|
||||||
one_minus_sqr_es_sin = ONE_MINUS_SQR(es_sin);
|
one_minus_sqr_e_sin = ONE_MINUS_SQR(e_sin);
|
||||||
delta_phi = (one_minus_sqr_es_sin * one_minus_sqr_es_sin)
|
delta_phi = (one_minus_sqr_e_sin * one_minus_sqr_e_sin)
|
||||||
/ (2.0 * cos(phi)) * (q / (_one_minus_es2) - sin_phi
|
/ (2.0 * cos(phi)) * (q / (_one_minus_es) - sin_phi
|
||||||
/ one_minus_sqr_es_sin + (log((1.0 - es_sin)
|
/ one_minus_sqr_e_sin + (log((1.0 - e_sin)
|
||||||
/ (1.0 + es_sin)) / (_two_es)));
|
/ (1.0 + e_sin)) / (_two_e)));
|
||||||
phi += delta_phi;
|
phi += delta_phi;
|
||||||
count --;
|
count --;
|
||||||
}
|
}
|
||||||
@ -216,9 +211,9 @@ Coordinates AlbersEqual::xy2ll(const PointD &p) const
|
|||||||
lon = _longitudeOrigin + theta / _n;
|
lon = _longitudeOrigin + theta / _n;
|
||||||
|
|
||||||
if (lon > M_PI)
|
if (lon > M_PI)
|
||||||
lon -= M_PI * 2;
|
lon -= M_2_PI;
|
||||||
if (lon < -M_PI)
|
if (lon < -M_PI)
|
||||||
lon += M_PI * 2;
|
lon += M_2_PI;
|
||||||
|
|
||||||
if (lon > M_PI)
|
if (lon > M_PI)
|
||||||
lon = M_PI;
|
lon = M_PI;
|
||||||
|
@ -27,11 +27,11 @@ private:
|
|||||||
double _rho0;
|
double _rho0;
|
||||||
double _C;
|
double _C;
|
||||||
double _n;
|
double _n;
|
||||||
|
double _e;
|
||||||
double _es;
|
double _es;
|
||||||
double _es2;
|
|
||||||
double _a_over_n;
|
double _a_over_n;
|
||||||
double _one_minus_es2;
|
double _one_minus_es;
|
||||||
double _two_es;
|
double _two_e;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ALBERSEQUAL_H
|
#endif // ALBERSEQUAL_H
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#define TL(m) ((m)->xy2pp((m)->bounds().topLeft()))
|
#define TL(m) ((m)->xy2pp((m)->bounds().topLeft()))
|
||||||
#define BR(m) ((m)->xy2pp((m)->bounds().bottomRight()))
|
#define BR(m) ((m)->xy2pp((m)->bounds().bottomRight()))
|
||||||
|
|
||||||
static bool resCmp(const OfflineMap *m1, const OfflineMap *m2)
|
static bool resCmp(OfflineMap *m1, OfflineMap *m2)
|
||||||
{
|
{
|
||||||
qreal r1, r2;
|
qreal r1, r2;
|
||||||
|
|
||||||
@ -161,20 +161,6 @@ QRectF Atlas::bounds() const
|
|||||||
return QRectF(QPointF(0, 0), s);
|
return QRectF(QPointF(0, 0), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal Atlas::resolution(const QRectF &rect) const
|
|
||||||
{
|
|
||||||
int idx = _zooms.at(_zoom).first;
|
|
||||||
|
|
||||||
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).last; i++) {
|
|
||||||
if (_bounds.at(i).xy.contains(rect.center())) {
|
|
||||||
idx = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _maps.at(idx)->resolution(rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Atlas::zoomFit(const QSize &size, const RectC &br)
|
int Atlas::zoomFit(const QSize &size, const RectC &br)
|
||||||
{
|
{
|
||||||
_zoom = 0;
|
_zoom = 0;
|
||||||
@ -276,7 +262,6 @@ void Atlas::draw(QPainter *painter, const QRectF &rect, bool block)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Multiple maps
|
// Multiple maps
|
||||||
painter->fillRect(rect, _backgroundColor);
|
|
||||||
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).last; i++) {
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).last; i++) {
|
||||||
QRectF ir = rect.intersected(_bounds.at(i).xy);
|
QRectF ir = rect.intersected(_bounds.at(i).xy);
|
||||||
if (!ir.isNull())
|
if (!ir.isNull())
|
||||||
|
@ -16,7 +16,6 @@ public:
|
|||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds() const;
|
||||||
qreal resolution(const QRectF &rect) const;
|
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
void setZoom(int zoom);
|
void setZoom(int zoom);
|
||||||
|
@ -7,6 +7,9 @@ CoordinateSystem::CoordinateSystem(int code)
|
|||||||
case 1035:
|
case 1035:
|
||||||
case 1039:
|
case 1039:
|
||||||
case 4400:
|
case 4400:
|
||||||
|
case 4402:
|
||||||
|
case 4404:
|
||||||
|
case 4405:
|
||||||
case 4409:
|
case 4409:
|
||||||
case 4463:
|
case 4463:
|
||||||
case 4464:
|
case 4464:
|
||||||
@ -26,6 +29,7 @@ CoordinateSystem::CoordinateSystem(int code)
|
|||||||
case 4530:
|
case 4530:
|
||||||
case 4531:
|
case 4531:
|
||||||
case 4532:
|
case 4532:
|
||||||
|
case 6501:
|
||||||
_axisOrder = YX;
|
_axisOrder = YX;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -12,6 +12,7 @@ public:
|
|||||||
CoordinateSystem(AxisOrder axisOrder) : _axisOrder(axisOrder) {}
|
CoordinateSystem(AxisOrder axisOrder) : _axisOrder(axisOrder) {}
|
||||||
CoordinateSystem(int code);
|
CoordinateSystem(int code);
|
||||||
|
|
||||||
|
bool isNull() const {return (_axisOrder == Unknown);}
|
||||||
bool isValid() const {return (_axisOrder != Unknown);}
|
bool isValid() const {return (_axisOrder != Unknown);}
|
||||||
|
|
||||||
AxisOrder axisOrder() const {return _axisOrder;}
|
AxisOrder axisOrder() const {return _axisOrder;}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
#include <cmath>
|
|
||||||
#include "common/wgs84.h"
|
#include "common/wgs84.h"
|
||||||
#include "datum.h"
|
#include "datum.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define as2rad(x) ((x) * (M_PI/648000.0))
|
||||||
|
#define rad2as(x) ((x) * (648000.0/M_PI))
|
||||||
|
#define ds2scale(x) (1.0 + (x) * 1e-6)
|
||||||
|
#define scale2ds(x) (((x) - 1.0) / 1e-6)
|
||||||
|
|
||||||
static Ellipsoid WGS84e = Ellipsoid(WGS84_RADIUS, WGS84_FLATTENING);
|
static Ellipsoid WGS84e = Ellipsoid(WGS84_RADIUS, WGS84_FLATTENING);
|
||||||
static Datum WGS84 = Datum(&WGS84e, 0.0, 0.0, 0.0);
|
static Datum WGS84 = Datum(&WGS84e, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
// Abridged Molodensky transformation
|
|
||||||
static Coordinates molodensky(const Coordinates &c, const Datum &from,
|
static Coordinates molodensky(const Coordinates &c, const Datum &from,
|
||||||
const Datum &to)
|
const Datum &to)
|
||||||
{
|
{
|
||||||
@ -32,40 +36,90 @@ static Coordinates molodensky(const Coordinates &c, const Datum &from,
|
|||||||
double adb = 1.0 / (1.0 - from_f);
|
double adb = 1.0 / (1.0 - from_f);
|
||||||
double rn = from_a / sqrt(1 - from_esq * ssqlat);
|
double rn = from_a / sqrt(1 - from_esq * ssqlat);
|
||||||
double rm = from_a * (1 - from_esq) / pow((1 - from_esq * ssqlat), 1.5);
|
double rm = from_a * (1 - from_esq) / pow((1 - from_esq * ssqlat), 1.5);
|
||||||
double from_h = 0.0;
|
|
||||||
|
|
||||||
double dlat = (-dx * slat * clon - dy * slat * slon + dz * clat + da
|
double dlat = (-dx * slat * clon - dy * slat * slon + dz * clat + da
|
||||||
* rn * from_esq * slat * clat / from_a + df * (rm * adb + rn / adb) * slat
|
* rn * from_esq * slat * clat / from_a + df * (rm * adb + rn / adb) * slat
|
||||||
* clat) / (rm + from_h);
|
* clat) / rm;
|
||||||
|
|
||||||
double dlon = (-dx * slon + dy * clon) / ((rn + from_h) * clat);
|
double dlon = (-dx * slon + dy * clon) / (rn * clat);
|
||||||
|
|
||||||
return Coordinates(c.lon() + rad2deg(dlon), c.lat() + rad2deg(dlat));
|
return Coordinates(c.lon() + rad2deg(dlon), c.lat() + rad2deg(dlat));
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum::Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz)
|
Point3D Datum::helmert(const Point3D &p) const
|
||||||
: _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz)
|
|
||||||
{
|
{
|
||||||
_WGS84 = (_ellipsoid->radius() == WGS84_RADIUS
|
return Point3D(_scale * (p.x() + _rz * p.y() -_ry * p.z()) + _dx,
|
||||||
&& _ellipsoid->flattening() == WGS84_FLATTENING && _dx == 0.0
|
_scale * (-_rz * p.x() + p.y() + _rx * p.z()) + _dy,
|
||||||
&& _dy == 0.0 && _dz == 0.0) ? true : false;
|
_scale * (_ry * p.x() -_rx * p.y() + p.z()) + _dz);
|
||||||
|
}
|
||||||
|
|
||||||
|
Point3D Datum::helmertr(const Point3D &p) const
|
||||||
|
{
|
||||||
|
double x = (p.x() - _dx) / _scale;
|
||||||
|
double y = (p.y() - _dy) / _scale;
|
||||||
|
double z = (p.z() - _dz) / _scale;
|
||||||
|
|
||||||
|
return Point3D(x -_rz * y + _ry * z, _rz * x + y + -_rx * z, -_ry * x + _rx
|
||||||
|
* y + z);
|
||||||
|
}
|
||||||
|
|
||||||
|
Datum::Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz,
|
||||||
|
double rx, double ry, double rz, double ds)
|
||||||
|
: _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz), _rx(as2rad(rx)),
|
||||||
|
_ry(as2rad(ry)), _rz(as2rad(rz)), _scale(ds2scale(ds))
|
||||||
|
{
|
||||||
|
if (_ellipsoid->radius() == WGS84_RADIUS && _ellipsoid->flattening()
|
||||||
|
== WGS84_FLATTENING && _dx == 0.0 && _dy == 0.0 && _dz == 0.0
|
||||||
|
&& _rx == 0.0 && _ry == 0.0 && _rz == 0.0 && ds == 0.0)
|
||||||
|
_transformation = None;
|
||||||
|
else
|
||||||
|
_transformation = Helmert;
|
||||||
|
}
|
||||||
|
|
||||||
|
Datum::Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz)
|
||||||
|
: _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz), _rx(0.0), _ry(0.0),
|
||||||
|
_rz(0.0), _scale(1.0)
|
||||||
|
{
|
||||||
|
if (_ellipsoid->radius() == WGS84_RADIUS && _ellipsoid->flattening()
|
||||||
|
== WGS84_FLATTENING && _dx == 0.0 && _dy == 0.0 && _dz == 0.0)
|
||||||
|
_transformation = None;
|
||||||
|
else
|
||||||
|
_transformation = Molodensky;
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates Datum::toWGS84(const Coordinates &c) const
|
Coordinates Datum::toWGS84(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
return _WGS84 ? c : molodensky(c, *this, WGS84);
|
switch (_transformation) {
|
||||||
|
case Helmert:
|
||||||
|
return Geocentric::toGeodetic(helmert(Geocentric::fromGeodetic(c,
|
||||||
|
ellipsoid())), WGS84.ellipsoid());
|
||||||
|
case Molodensky:
|
||||||
|
return molodensky(c, *this, WGS84);
|
||||||
|
default:
|
||||||
|
return c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates Datum::fromWGS84(const Coordinates &c) const
|
Coordinates Datum::fromWGS84(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
return _WGS84 ? c : molodensky(c, WGS84, *this);
|
switch (_transformation) {
|
||||||
|
case Helmert:
|
||||||
|
return Geocentric::toGeodetic(helmertr(Geocentric::fromGeodetic(c,
|
||||||
|
WGS84.ellipsoid())), ellipsoid());
|
||||||
|
case Molodensky:
|
||||||
|
return molodensky(c, WGS84, *this);
|
||||||
|
default:
|
||||||
|
return c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
QDebug operator<<(QDebug dbg, const Datum &datum)
|
QDebug operator<<(QDebug dbg, const Datum &datum)
|
||||||
{
|
{
|
||||||
dbg.nospace() << "Datum(" << *datum.ellipsoid() << ", " << datum.dx()
|
dbg.nospace() << "Datum(" << *datum.ellipsoid() << ", " << datum.dx()
|
||||||
<< ", " << datum.dy() << ", " << datum.dz() << ")";
|
<< ", " << datum.dy() << ", " << datum.dz() << ", " << rad2as(datum.rx())
|
||||||
|
<< ", " << rad2as(datum.ry()) << ", " << rad2as(datum.rz()) << ", "
|
||||||
|
<< scale2ds(datum.scale()) << ")";
|
||||||
return dbg.space();
|
return dbg.space();
|
||||||
}
|
}
|
||||||
#endif // QT_NO_DEBUG
|
#endif // QT_NO_DEBUG
|
||||||
|
@ -2,42 +2,58 @@
|
|||||||
#define DATUM_H
|
#define DATUM_H
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QList>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "ellipsoid.h"
|
|
||||||
#include "common/coordinates.h"
|
#include "common/coordinates.h"
|
||||||
|
#include "ellipsoid.h"
|
||||||
|
#include "geocentric.h"
|
||||||
|
|
||||||
class Datum
|
class Datum
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Datum() : _ellipsoid(0), _dx(NAN), _dy(NAN), _dz(NAN),
|
Datum() : _ellipsoid(0), _transformation(None), _dx(NAN), _dy(NAN),
|
||||||
_WGS84(false) {}
|
_dz(NAN), _rx(NAN), _ry(NAN), _rz(NAN), _scale(NAN) {}
|
||||||
|
Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz,
|
||||||
|
double rx, double ry, double rz, double ds);
|
||||||
Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz);
|
Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz);
|
||||||
|
|
||||||
const Ellipsoid *ellipsoid() const {return _ellipsoid;}
|
const Ellipsoid *ellipsoid() const {return _ellipsoid;}
|
||||||
double dx() const {return _dx;}
|
double dx() const {return _dx;}
|
||||||
double dy() const {return _dy;}
|
double dy() const {return _dy;}
|
||||||
double dz() const {return _dz;}
|
double dz() const {return _dz;}
|
||||||
|
double rx() const {return _rx;}
|
||||||
|
double ry() const {return _ry;}
|
||||||
|
double rz() const {return _rz;}
|
||||||
|
double scale() const {return _scale;}
|
||||||
|
|
||||||
bool isNull() const
|
bool isNull() const
|
||||||
{return (!_ellipsoid && std::isnan(_dx) && std::isnan(_dy)
|
{return !_ellipsoid;}
|
||||||
&& std::isnan(_dz));}
|
|
||||||
bool isValid() const
|
bool isValid() const
|
||||||
{return (_ellipsoid && !std::isnan(_dx) && !std::isnan(_dy)
|
{return (_ellipsoid && !std::isnan(_dx) && !std::isnan(_dy)
|
||||||
&& !std::isnan(_dz));}
|
&& !std::isnan(_dz) && !std::isnan(_scale) && !std::isnan(_rx)
|
||||||
|
&& !std::isnan(_ry) && !std::isnan(_rz));}
|
||||||
|
|
||||||
Coordinates toWGS84(const Coordinates &c) const;
|
Coordinates toWGS84(const Coordinates &c) const;
|
||||||
Coordinates fromWGS84(const Coordinates &c) const;
|
Coordinates fromWGS84(const Coordinates &c) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum TransformationType {
|
||||||
|
None,
|
||||||
|
Molodensky,
|
||||||
|
Helmert
|
||||||
|
};
|
||||||
|
|
||||||
|
Point3D helmert(const Point3D &p) const;
|
||||||
|
Point3D helmertr(const Point3D &p) const;
|
||||||
|
|
||||||
const Ellipsoid *_ellipsoid;
|
const Ellipsoid *_ellipsoid;
|
||||||
double _dx, _dy, _dz;
|
TransformationType _transformation;
|
||||||
bool _WGS84;
|
double _dx, _dy, _dz, _rx, _ry, _rz, _scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const Datum &d1, const Datum &d2)
|
inline bool operator==(const Datum &d1, const Datum &d2)
|
||||||
{return (d1.ellipsoid() == d2.ellipsoid() && d1.dx() == d2.dx()
|
{return (*d1.ellipsoid() == *d2.ellipsoid() && d1.dx() == d2.dx()
|
||||||
&& d1.dy() == d2.dy() && d1.dz() == d2.dz());}
|
&& d1.dy() == d2.dy() && d1.dz() == d2.dz() && d1.rx() == d2.rx()
|
||||||
|
&& d1.ry() == d2.ry() && d1.rz() == d2.rz() && d1.scale() == d2.scale());}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
QDebug operator<<(QDebug dbg, const Datum &datum);
|
QDebug operator<<(QDebug dbg, const Datum &datum);
|
||||||
|
@ -3,12 +3,18 @@
|
|||||||
#include "common/wgs84.h"
|
#include "common/wgs84.h"
|
||||||
#include "ellipsoid.h"
|
#include "ellipsoid.h"
|
||||||
|
|
||||||
QMap<int, Ellipsoid> Ellipsoid::_ellipsoids = WGS84();
|
QMap<int, Ellipsoid> Ellipsoid::_ellipsoids = defaults();
|
||||||
|
|
||||||
QMap<int, Ellipsoid> Ellipsoid::WGS84()
|
const Ellipsoid &Ellipsoid::WGS84()
|
||||||
|
{
|
||||||
|
static Ellipsoid e(WGS84_RADIUS, WGS84_FLATTENING);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<int, Ellipsoid> Ellipsoid::defaults()
|
||||||
{
|
{
|
||||||
QMap<int, Ellipsoid> map;
|
QMap<int, Ellipsoid> map;
|
||||||
map.insert(7030, Ellipsoid(WGS84_RADIUS, WGS84_FLATTENING));
|
map.insert(7030, WGS84());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +72,14 @@ void Ellipsoid::loadList(const QString &path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ellipsoid::Ellipsoid(double radius, double flattening)
|
||||||
|
: _radius(radius), _flattening(flattening)
|
||||||
|
{
|
||||||
|
_es = 2.0 * flattening - flattening * flattening;
|
||||||
|
_e2s = (1.0 / (1.0 - _es)) - 1.0;
|
||||||
|
_b = radius * (1.0 - flattening);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
QDebug operator<<(QDebug dbg, const Ellipsoid &ellipsoid)
|
QDebug operator<<(QDebug dbg, const Ellipsoid &ellipsoid)
|
||||||
{
|
{
|
||||||
|
@ -9,26 +9,30 @@
|
|||||||
class Ellipsoid
|
class Ellipsoid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Ellipsoid() : _radius(NAN), _flattening(NAN) {}
|
Ellipsoid() : _radius(NAN), _flattening(NAN), _es(NAN), _b(NAN) {}
|
||||||
Ellipsoid(double radius, double flattening)
|
Ellipsoid(double radius, double flattening);
|
||||||
: _radius(radius), _flattening(flattening) {}
|
|
||||||
|
|
||||||
double radius() const {return _radius;}
|
double radius() const {return _radius;}
|
||||||
double flattening() const {return _flattening;}
|
double flattening() const {return _flattening;}
|
||||||
|
double es() const {return _es;}
|
||||||
|
double e2s() const {return _e2s;}
|
||||||
|
double b() const {return _b;}
|
||||||
|
|
||||||
bool isNull() const
|
bool isNull() const
|
||||||
{return (std::isnan(_radius) && std::isnan(_flattening));}
|
{return (std::isnan(_radius) && std::isnan(_flattening));}
|
||||||
bool isValid() const
|
bool isValid() const
|
||||||
{return !(std::isnan(_radius) || std::isnan(_flattening));}
|
{return !(std::isnan(_radius) || std::isnan(_flattening));}
|
||||||
|
|
||||||
|
static const Ellipsoid &WGS84();
|
||||||
static const Ellipsoid *ellipsoid(int id);
|
static const Ellipsoid *ellipsoid(int id);
|
||||||
static void loadList(const QString &path);
|
static void loadList(const QString &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double _radius;
|
double _radius;
|
||||||
double _flattening;
|
double _flattening;
|
||||||
|
double _es, _e2s, _b;
|
||||||
|
|
||||||
static QMap<int, Ellipsoid> WGS84();
|
static QMap<int, Ellipsoid> defaults();
|
||||||
static QMap<int, Ellipsoid> _ellipsoids;
|
static QMap<int, Ellipsoid> _ellipsoids;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
static QPointF ll2m(const Coordinates &c)
|
static QPointF ll2m(const Coordinates &c)
|
||||||
{
|
{
|
||||||
return QPointF(c.lon(), rad2deg(log(tan(M_PI/4.0 + deg2rad(c.lat())/2.0))));
|
return QPointF(c.lon(), rad2deg(log(tan(M_PI_4 + deg2rad(c.lat())/2.0))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Coordinates m2ll(const QPointF &p)
|
static Coordinates m2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
return Coordinates(p.x(), rad2deg(2 * atan(exp(deg2rad(p.y()))) - M_PI/2));
|
return Coordinates(p.x(), rad2deg(2.0 * atan(exp(deg2rad(p.y()))) - M_PI_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal zoom2scale(int zoom)
|
static qreal zoom2scale(int zoom)
|
||||||
@ -65,7 +65,7 @@ int EmptyMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal EmptyMap::resolution(const QRectF &rect) const
|
qreal EmptyMap::resolution(const QRectF &rect)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = zoom2scale(_zoom);
|
||||||
|
|
||||||
@ -87,8 +87,9 @@ int EmptyMap::zoomOut()
|
|||||||
|
|
||||||
void EmptyMap::draw(QPainter *painter, const QRectF &rect, bool block)
|
void EmptyMap::draw(QPainter *painter, const QRectF &rect, bool block)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(painter);
|
||||||
|
Q_UNUSED(rect);
|
||||||
Q_UNUSED(block);
|
Q_UNUSED(block);
|
||||||
painter->fillRect(rect, _backgroundColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF EmptyMap::ll2xy(const Coordinates &c) const
|
QPointF EmptyMap::ll2xy(const Coordinates &c) const
|
||||||
|
@ -13,7 +13,7 @@ public:
|
|||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds() const;
|
||||||
qreal resolution(const QRectF &rect) const;
|
qreal resolution(const QRectF &rect);
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
void setZoom(int zoom) {_zoom = zoom;}
|
void setZoom(int zoom) {_zoom = zoom;}
|
||||||
|
@ -19,9 +19,6 @@ private:
|
|||||||
GCS _gcs;
|
GCS _gcs;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Ellipsoid WGS84e = Ellipsoid(WGS84_RADIUS, WGS84_FLATTENING);
|
|
||||||
static Datum WGS84d = Datum(&WGS84e, 0.0, 0.0, 0.0);
|
|
||||||
|
|
||||||
static int parameter(const QString &str, bool *res)
|
static int parameter(const QString &str, bool *res)
|
||||||
{
|
{
|
||||||
QString field = str.trimmed();
|
QString field = str.trimmed();
|
||||||
@ -33,12 +30,31 @@ static int parameter(const QString &str, bool *res)
|
|||||||
return field.toInt(res);
|
return field.toInt(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<GCS::Entry> GCS::_gcss = WGS84();
|
static double parameterd(const QString &str, bool *res)
|
||||||
|
{
|
||||||
|
QString field = str.trimmed();
|
||||||
|
if (field.isEmpty()) {
|
||||||
|
*res = true;
|
||||||
|
return NAN;
|
||||||
|
}
|
||||||
|
|
||||||
QList<GCS::Entry> GCS::WGS84()
|
return field.toDouble(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<GCS::Entry> GCS::_gcss = defaults();
|
||||||
|
|
||||||
|
const GCS &GCS::WGS84()
|
||||||
|
{
|
||||||
|
static Datum d(&Ellipsoid::WGS84(), 0.0, 0.0, 0.0);
|
||||||
|
static GCS g(d, 8901, 9122);
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<GCS::Entry> GCS::defaults()
|
||||||
{
|
{
|
||||||
QList<GCS::Entry> list;
|
QList<GCS::Entry> list;
|
||||||
list.append(GCS::Entry(4326, 6326, "WGS 84", GCS(WGS84d, 8901, 9122)));
|
list.append(GCS::Entry(4326, 6326, "WGS 84", WGS84()));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +107,7 @@ void GCS::loadList(const QString &path)
|
|||||||
|
|
||||||
QByteArray line = file.readLine();
|
QByteArray line = file.readLine();
|
||||||
QList<QByteArray> list = line.split(',');
|
QList<QByteArray> list = line.split(',');
|
||||||
if (list.size() < 10) {
|
if (list.size() != 14) {
|
||||||
qWarning("%s:%d: Format error", qPrintable(path), ln);
|
qWarning("%s:%d: Format error", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -145,6 +161,26 @@ void GCS::loadList(const QString &path)
|
|||||||
qWarning("%s:%d: Invalid dz", qPrintable(path), ln);
|
qWarning("%s:%d: Invalid dz", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
double rx = parameterd(list[10], &res);
|
||||||
|
if (!res) {
|
||||||
|
qWarning("%s:%d: Invalid rx", qPrintable(path), ln);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
double ry = parameterd(list[11], &res);
|
||||||
|
if (!res) {
|
||||||
|
qWarning("%s:%d: Invalid ry", qPrintable(path), ln);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
double rz = parameterd(list[12], &res);
|
||||||
|
if (!res) {
|
||||||
|
qWarning("%s:%d: Invalid rz", qPrintable(path), ln);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
double ds = parameterd(list[13], &res);
|
||||||
|
if (!res) {
|
||||||
|
qWarning("%s:%d: Invalid ds", qPrintable(path), ln);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(e = Ellipsoid::ellipsoid(el))) {
|
if (!(e = Ellipsoid::ellipsoid(el))) {
|
||||||
qWarning("%s:%d: Unknown ellipsoid code", qPrintable(path), ln);
|
qWarning("%s:%d: Unknown ellipsoid code", qPrintable(path), ln);
|
||||||
@ -156,11 +192,22 @@ void GCS::loadList(const QString &path)
|
|||||||
case 9603:
|
case 9603:
|
||||||
datum = Datum(e, dx, dy, dz);
|
datum = Datum(e, dx, dy, dz);
|
||||||
break;
|
break;
|
||||||
|
case 9606:
|
||||||
|
datum = Datum(e, dx, dy, dz, -rx, -ry, -rz, ds);
|
||||||
|
break;
|
||||||
|
case 9607:
|
||||||
|
datum = Datum(e, dx, dy, dz, rx, ry, rz, ds);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning("%s:%d: Unknown coordinates transformation method",
|
qWarning("%s:%d: Unknown coordinates transformation method",
|
||||||
qPrintable(path), ln);
|
qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!datum.isValid()) {
|
||||||
|
qWarning("%s:%d: Invalid coordinates transformation parameters",
|
||||||
|
qPrintable(path), ln);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
GCS gcs(datum, pm, au);
|
GCS gcs(datum, pm, au);
|
||||||
if (gcs.isValid())
|
if (gcs.isValid())
|
||||||
|
@ -29,13 +29,14 @@ public:
|
|||||||
static const GCS *gcs(int geodeticDatum, int primeMeridian,
|
static const GCS *gcs(int geodeticDatum, int primeMeridian,
|
||||||
int angularUnits);
|
int angularUnits);
|
||||||
static const GCS *gcs(const QString &name);
|
static const GCS *gcs(const QString &name);
|
||||||
|
static const GCS &WGS84();
|
||||||
|
|
||||||
static void loadList(const QString &path);
|
static void loadList(const QString &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Entry;
|
class Entry;
|
||||||
|
|
||||||
static QList<Entry> WGS84();
|
static QList<Entry> defaults();
|
||||||
|
|
||||||
Datum _datum;
|
Datum _datum;
|
||||||
PrimeMeridian _primeMeridian;
|
PrimeMeridian _primeMeridian;
|
||||||
|
106
src/map/geocentric.cpp
Normal file
106
src/map/geocentric.cpp
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Based on libgeotrans with the following Source Code Disclaimer:
|
||||||
|
|
||||||
|
1. The GEOTRANS source code ("the software") is provided free of charge by
|
||||||
|
the National Imagery and Mapping Agency (NIMA) of the United States
|
||||||
|
Department of Defense. Although NIMA makes no copyright claim under Title 17
|
||||||
|
U.S.C., NIMA claims copyrights in the source code under other legal regimes.
|
||||||
|
NIMA hereby grants to each user of the software a license to use and
|
||||||
|
distribute the software, and develop derivative works.
|
||||||
|
|
||||||
|
2. Warranty Disclaimer: The software was developed to meet only the internal
|
||||||
|
requirements of the U.S. National Imagery and Mapping Agency. The software
|
||||||
|
is provided "as is," and no warranty, express or implied, including but not
|
||||||
|
limited to the implied warranties of merchantability and fitness for
|
||||||
|
particular purpose or arising by statute or otherwise in law or from a
|
||||||
|
course of dealing or usage in trade, is made by NIMA as to the accuracy and
|
||||||
|
functioning of the software.
|
||||||
|
|
||||||
|
3. NIMA and its personnel are not required to provide technical support or
|
||||||
|
general assistance with respect to the software.
|
||||||
|
|
||||||
|
4. Neither NIMA nor its personnel will be liable for any claims, losses, or
|
||||||
|
damages arising from or connected with the use of the software. The user
|
||||||
|
agrees to hold harmless the United States National Imagery and Mapping
|
||||||
|
Agency. The user's sole and exclusive remedy is to stop using the software.
|
||||||
|
|
||||||
|
5. NIMA requests that products developed using the software credit the
|
||||||
|
source of the software with the following statement, "The product was
|
||||||
|
developed using GEOTRANS, a product of the National Imagery and Mapping
|
||||||
|
Agency and U.S. Army Engineering Research and Development Center."
|
||||||
|
|
||||||
|
6. For any products developed using the software, NIMA requires a disclaimer
|
||||||
|
that use of the software does not indicate endorsement or approval of the
|
||||||
|
product by the Secretary of Defense or the National Imagery and Mapping
|
||||||
|
Agency. Pursuant to the United States Code, 10 U.S.C. Sec. 2797, the name of
|
||||||
|
the National Imagery and Mapping Agency, the initials "NIMA", the seal of
|
||||||
|
the National Imagery and Mapping Agency, or any colorable imitation thereof
|
||||||
|
shall not be used to imply approval, endorsement, or authorization of a
|
||||||
|
product without prior written permission from United States Secretary of
|
||||||
|
Defense.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ellipsoid.h"
|
||||||
|
#include "geocentric.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define AD_C 1.0026000
|
||||||
|
|
||||||
|
Point3D Geocentric::fromGeodetic(const Coordinates &c, const Ellipsoid *e)
|
||||||
|
{
|
||||||
|
double lat = deg2rad(c.lat());
|
||||||
|
double lon = deg2rad(c.lon());
|
||||||
|
double slat = sin(lat);
|
||||||
|
double slat2 = slat * slat;
|
||||||
|
double clat = cos(lat);
|
||||||
|
double Rn = e->radius() / (sqrt(1.0 - e->es() * slat2));
|
||||||
|
|
||||||
|
if (lon > M_PI)
|
||||||
|
lon -= M_2_PI;
|
||||||
|
|
||||||
|
return Point3D(Rn * clat * cos(lon), Rn * clat * sin(lon),
|
||||||
|
(Rn * (1 - e->es())) * slat);
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates Geocentric::toGeodetic(const Point3D &p, const Ellipsoid *e)
|
||||||
|
{
|
||||||
|
bool pole = false;
|
||||||
|
double lat, lon;
|
||||||
|
|
||||||
|
if (p.x() == 0.0) {
|
||||||
|
if (p.y() > 0)
|
||||||
|
lon = M_PI_2;
|
||||||
|
else if (p.y() < 0)
|
||||||
|
lon = -M_PI_2;
|
||||||
|
else {
|
||||||
|
pole = true;
|
||||||
|
lon = 0.0;
|
||||||
|
if (p.z() > 0.0)
|
||||||
|
lat = M_PI_2;
|
||||||
|
else if (p.z() < 0.0)
|
||||||
|
lat = -M_PI_2;
|
||||||
|
else
|
||||||
|
return Coordinates(rad2deg(lon), rad2deg(M_PI_2));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
lon = atan2(p.y(), p.x());
|
||||||
|
|
||||||
|
double W2 = p.x()*p.x() + p.y()*p.y();
|
||||||
|
double W = sqrt(W2);
|
||||||
|
double T0 = p.z() * AD_C;
|
||||||
|
double S0 = sqrt(T0 * T0 + W2);
|
||||||
|
double Sin_B0 = T0 / S0;
|
||||||
|
double Cos_B0 = W / S0;
|
||||||
|
double Sin3_B0 = Sin_B0 * Sin_B0 * Sin_B0;
|
||||||
|
double T1 = p.z() + e->b() * e->e2s() * Sin3_B0;
|
||||||
|
double Sum = W - e->radius() * e->es() * Cos_B0 * Cos_B0 * Cos_B0;
|
||||||
|
double S1 = sqrt(T1*T1 + Sum * Sum);
|
||||||
|
double Sin_p1 = T1 / S1;
|
||||||
|
double Cos_p1 = Sum / S1;
|
||||||
|
|
||||||
|
if (!pole)
|
||||||
|
lat = atan(Sin_p1 / Cos_p1);
|
||||||
|
|
||||||
|
return Coordinates(rad2deg(lon), rad2deg(lat));
|
||||||
|
}
|
29
src/map/geocentric.h
Normal file
29
src/map/geocentric.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef GEOCENTRIC_H
|
||||||
|
#define GEOCENTRIC_H
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include "common/coordinates.h"
|
||||||
|
|
||||||
|
class Ellipsoid;
|
||||||
|
|
||||||
|
class Point3D {
|
||||||
|
public:
|
||||||
|
Point3D() : _x(NAN), _y(NAN), _z(NAN) {}
|
||||||
|
Point3D(double x, double y, double z) : _x(x), _y(y), _z(z) {}
|
||||||
|
|
||||||
|
double x() const {return _x;}
|
||||||
|
double y() const {return _y;}
|
||||||
|
double z() const {return _z;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
double _x;
|
||||||
|
double _y;
|
||||||
|
double _z;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Geocentric {
|
||||||
|
Point3D fromGeodetic(const Coordinates &c, const Ellipsoid *e);
|
||||||
|
Coordinates toGeodetic(const Point3D &p, const Ellipsoid *e);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GEOCENTRIC_H
|
@ -1,5 +1,3 @@
|
|||||||
#include <QFileInfo>
|
|
||||||
#include <QtEndian>
|
|
||||||
#include "pcs.h"
|
#include "pcs.h"
|
||||||
#include "tifffile.h"
|
#include "tifffile.h"
|
||||||
#include "geotiff.h"
|
#include "geotiff.h"
|
||||||
@ -9,48 +7,51 @@
|
|||||||
#define TIFF_SHORT 3
|
#define TIFF_SHORT 3
|
||||||
#define TIFF_LONG 4
|
#define TIFF_LONG 4
|
||||||
|
|
||||||
#define ModelPixelScaleTag 33550
|
#define ModelPixelScaleTag 33550
|
||||||
#define ModelTiepointTag 33922
|
#define ModelTiepointTag 33922
|
||||||
#define ModelTransformationTag 34264
|
#define ModelTransformationTag 34264
|
||||||
#define GeoKeyDirectoryTag 34735
|
#define GeoKeyDirectoryTag 34735
|
||||||
#define GeoDoubleParamsTag 34736
|
#define GeoDoubleParamsTag 34736
|
||||||
|
|
||||||
#define GTModelTypeGeoKey 1024
|
#define GTModelTypeGeoKey 1024
|
||||||
#define GTRasterTypeGeoKey 1025
|
#define GTRasterTypeGeoKey 1025
|
||||||
#define GeographicTypeGeoKey 2048
|
#define GeographicTypeGeoKey 2048
|
||||||
#define GeogGeodeticDatumGeoKey 2050
|
#define GeogGeodeticDatumGeoKey 2050
|
||||||
#define GeogPrimeMeridianGeoKey 2051
|
#define GeogPrimeMeridianGeoKey 2051
|
||||||
#define GeogAngularUnitsGeoKey 2054
|
#define GeogAngularUnitsGeoKey 2054
|
||||||
#define GeogEllipsoidGeoKey 2056
|
#define GeogEllipsoidGeoKey 2056
|
||||||
#define GeogAzimuthUnitsGeoKey 2060
|
#define GeogAzimuthUnitsGeoKey 2060
|
||||||
#define ProjectedCSTypeGeoKey 3072
|
#define ProjectedCSTypeGeoKey 3072
|
||||||
#define ProjectionGeoKey 3074
|
#define ProjectionGeoKey 3074
|
||||||
#define ProjCoordTransGeoKey 3075
|
#define ProjCoordTransGeoKey 3075
|
||||||
#define ProjLinearUnitsGeoKey 3076
|
#define ProjLinearUnitsGeoKey 3076
|
||||||
#define ProjStdParallel1GeoKey 3078
|
#define ProjStdParallel1GeoKey 3078
|
||||||
#define ProjStdParallel2GeoKey 3079
|
#define ProjStdParallel2GeoKey 3079
|
||||||
#define ProjNatOriginLongGeoKey 3080
|
#define ProjNatOriginLongGeoKey 3080
|
||||||
#define ProjNatOriginLatGeoKey 3081
|
#define ProjNatOriginLatGeoKey 3081
|
||||||
#define ProjFalseEastingGeoKey 3082
|
#define ProjFalseEastingGeoKey 3082
|
||||||
#define ProjFalseNorthingGeoKey 3083
|
#define ProjFalseNorthingGeoKey 3083
|
||||||
#define ProjCenterLongGeoKey 3088
|
#define ProjFalseOriginLatGeoKey 3085
|
||||||
#define ProjCenterLatGeoKey 3089
|
#define ProjCenterLongGeoKey 3088
|
||||||
#define ProjScaleAtNatOriginGeoKey 3092
|
#define ProjCenterLatGeoKey 3089
|
||||||
#define ProjScaleAtCenterGeoKey 3093
|
#define ProjCenterEastingGeoKey 3090
|
||||||
#define ProjAzimuthAngleGeoKey 3094
|
#define ProjFalseOriginNorthingGeoKey 3091
|
||||||
#define ProjRectifiedGridAngleGeoKey 3096
|
#define ProjScaleAtNatOriginGeoKey 3092
|
||||||
|
#define ProjScaleAtCenterGeoKey 3093
|
||||||
|
#define ProjAzimuthAngleGeoKey 3094
|
||||||
|
#define ProjRectifiedGridAngleGeoKey 3096
|
||||||
|
|
||||||
#define ModelTypeProjected 1
|
#define ModelTypeProjected 1
|
||||||
#define ModelTypeGeographic 2
|
#define ModelTypeGeographic 2
|
||||||
#define ModelTypeGeocentric 3
|
#define ModelTypeGeocentric 3
|
||||||
|
|
||||||
#define CT_TransverseMercator 1
|
#define CT_TransverseMercator 1
|
||||||
#define CT_ObliqueMercator 3
|
#define CT_ObliqueMercator 3
|
||||||
#define CT_Mercator 7
|
#define CT_Mercator 7
|
||||||
#define CT_LambertConfConic_2SP 8
|
#define CT_LambertConfConic_2SP 8
|
||||||
#define CT_LambertConfConic_1SP 9
|
#define CT_LambertConfConic_1SP 9
|
||||||
#define CT_LambertAzimEqualArea 10
|
#define CT_LambertAzimEqualArea 10
|
||||||
#define CT_AlbersEqualArea 11
|
#define CT_AlbersEqualArea 11
|
||||||
|
|
||||||
|
|
||||||
#define IS_SET(map, key) \
|
#define IS_SET(map, key) \
|
||||||
@ -251,6 +252,9 @@ bool GeoTIFF::readKeys(TIFFFile &file, Ctx &ctx, QMap<quint16, Value> &kv) const
|
|||||||
case ProjScaleAtCenterGeoKey:
|
case ProjScaleAtCenterGeoKey:
|
||||||
case ProjAzimuthAngleGeoKey:
|
case ProjAzimuthAngleGeoKey:
|
||||||
case ProjRectifiedGridAngleGeoKey:
|
case ProjRectifiedGridAngleGeoKey:
|
||||||
|
case ProjFalseOriginLatGeoKey:
|
||||||
|
case ProjCenterEastingGeoKey:
|
||||||
|
case ProjFalseOriginNorthingGeoKey:
|
||||||
if (!readGeoValue(file, ctx.values, entry.ValueOffset,
|
if (!readGeoValue(file, ctx.values, entry.ValueOffset,
|
||||||
value.DOUBLE))
|
value.DOUBLE))
|
||||||
return false;
|
return false;
|
||||||
@ -325,7 +329,7 @@ Projection::Method GeoTIFF::method(QMap<quint16, Value> &kv)
|
|||||||
case CT_ObliqueMercator:
|
case CT_ObliqueMercator:
|
||||||
return Projection::Method(9815);
|
return Projection::Method(9815);
|
||||||
case CT_Mercator:
|
case CT_Mercator:
|
||||||
return Projection::Method(1024);
|
return Projection::Method(9804);
|
||||||
case CT_LambertConfConic_2SP:
|
case CT_LambertConfConic_2SP:
|
||||||
return Projection::Method(9802);
|
return Projection::Method(9802);
|
||||||
case CT_LambertConfConic_1SP:
|
case CT_LambertConfConic_1SP:
|
||||||
@ -389,6 +393,8 @@ bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
|
|||||||
lat0 = au.toDegrees(kv.value(ProjNatOriginLatGeoKey).DOUBLE);
|
lat0 = au.toDegrees(kv.value(ProjNatOriginLatGeoKey).DOUBLE);
|
||||||
else if (kv.contains(ProjCenterLatGeoKey))
|
else if (kv.contains(ProjCenterLatGeoKey))
|
||||||
lat0 = au.toDegrees(kv.value(ProjCenterLatGeoKey).DOUBLE);
|
lat0 = au.toDegrees(kv.value(ProjCenterLatGeoKey).DOUBLE);
|
||||||
|
else if (kv.contains(ProjFalseOriginLatGeoKey))
|
||||||
|
lat0 = au.toDegrees(kv.value(ProjFalseOriginLatGeoKey).DOUBLE);
|
||||||
else
|
else
|
||||||
lat0 = NAN;
|
lat0 = NAN;
|
||||||
if (kv.contains(ProjNatOriginLongGeoKey))
|
if (kv.contains(ProjNatOriginLongGeoKey))
|
||||||
@ -417,10 +423,14 @@ bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
|
|||||||
sp2 = NAN;
|
sp2 = NAN;
|
||||||
if (kv.contains(ProjFalseNorthingGeoKey))
|
if (kv.contains(ProjFalseNorthingGeoKey))
|
||||||
fn = lu.toMeters(kv.value(ProjFalseNorthingGeoKey).DOUBLE);
|
fn = lu.toMeters(kv.value(ProjFalseNorthingGeoKey).DOUBLE);
|
||||||
|
else if (kv.contains(ProjFalseOriginNorthingGeoKey))
|
||||||
|
fn = lu.toMeters(kv.value(ProjFalseOriginNorthingGeoKey).DOUBLE);
|
||||||
else
|
else
|
||||||
fn = NAN;
|
fn = NAN;
|
||||||
if (kv.contains(ProjFalseEastingGeoKey))
|
if (kv.contains(ProjFalseEastingGeoKey))
|
||||||
fe = lu.toMeters(kv.value(ProjFalseEastingGeoKey).DOUBLE);
|
fe = lu.toMeters(kv.value(ProjFalseEastingGeoKey).DOUBLE);
|
||||||
|
else if (kv.contains(ProjCenterEastingGeoKey))
|
||||||
|
fe = lu.toMeters(kv.value(ProjCenterEastingGeoKey).DOUBLE);
|
||||||
else
|
else
|
||||||
fe = NAN;
|
fe = NAN;
|
||||||
|
|
||||||
|
247
src/map/jnxmap.cpp
Normal file
247
src/map/jnxmap.cpp
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
#include <QtEndian>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QPixmapCache>
|
||||||
|
#include "rectd.h"
|
||||||
|
#include "jnxmap.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define ic2dc(x) ((x) * 180.0 / 0x7FFFFFFF)
|
||||||
|
|
||||||
|
struct Level {
|
||||||
|
quint32 count;
|
||||||
|
quint32 offset;
|
||||||
|
quint32 scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Ctx {
|
||||||
|
QPainter *painter;
|
||||||
|
QFile *file;
|
||||||
|
|
||||||
|
Ctx(QPainter *painter, QFile *file) : painter(painter), file(file) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class T> bool JNXMap::readValue(T &val)
|
||||||
|
{
|
||||||
|
T data;
|
||||||
|
|
||||||
|
if (_file.read((char*)&data, sizeof(T)) < (qint64)sizeof(T))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (sizeof(T) > 1)
|
||||||
|
val = qFromLittleEndian(data);
|
||||||
|
else
|
||||||
|
val = data;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JNXMap::readString(QByteArray& ba)
|
||||||
|
{
|
||||||
|
char byte;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (!_file.getChar(&byte))
|
||||||
|
return false;
|
||||||
|
else if (!byte)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
ba += byte;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JNXMap::readTiles()
|
||||||
|
{
|
||||||
|
qint32 lat1, lon2, lat2, lon1;
|
||||||
|
quint32 version, dummy, levels;
|
||||||
|
|
||||||
|
if (!(readValue(version) && readValue(dummy) && readValue(lat1)
|
||||||
|
&& readValue(lon2) && readValue(lat2) && readValue(lon1)
|
||||||
|
&& readValue(levels)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_bounds = RectC(Coordinates(ic2dc(lon1), ic2dc(lat1)),
|
||||||
|
Coordinates(ic2dc(lon2), ic2dc(lat2)));
|
||||||
|
if (!levels || !_bounds.isValid())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!_file.seek(version > 3 ? 0x34 : 0x30))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QVector<Level> lh(levels);
|
||||||
|
for (int i = 0; i < lh.count(); i++) {
|
||||||
|
Level &l = lh[i];
|
||||||
|
|
||||||
|
if (!(readValue(l.count) && readValue(l.offset) && readValue(l.scale)))
|
||||||
|
return false;
|
||||||
|
if (version > 3) {
|
||||||
|
QByteArray ba;
|
||||||
|
if (!(readValue(dummy) && readString(ba)))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_zooms = QVector<Zoom>(lh.size());
|
||||||
|
for (int i = 0; i < lh.count(); i++) {
|
||||||
|
Zoom &z = _zooms[i];
|
||||||
|
const Level &l = lh.at(i);
|
||||||
|
|
||||||
|
if (!_file.seek(l.offset))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
z.tiles = QVector<Tile>(l.count);
|
||||||
|
for (quint32 j = 0; j < l.count; j++) {
|
||||||
|
Tile &tile = z.tiles[j];
|
||||||
|
qint32 top, right, bottom, left;
|
||||||
|
quint16 width, height;
|
||||||
|
|
||||||
|
if (!(readValue(top) && readValue(right) && readValue(bottom)
|
||||||
|
&& readValue(left) && readValue(width)
|
||||||
|
&& readValue(height) && readValue(tile.size)
|
||||||
|
&& readValue(tile.offset)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
RectD rect(PointD(ic2dc(left), ic2dc(top)), PointD(ic2dc(right),
|
||||||
|
ic2dc(bottom)));
|
||||||
|
|
||||||
|
if (j == 0) {
|
||||||
|
ReferencePoint tl(PointD(0, 0), rect.topLeft());
|
||||||
|
ReferencePoint br(PointD(width, height), rect.bottomRight());
|
||||||
|
z.transform = Transform(tl, br);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF trect(z.transform.proj2img(rect.topLeft()),
|
||||||
|
z.transform.proj2img(rect.bottomRight()));
|
||||||
|
tile.pos = trect.topLeft();
|
||||||
|
|
||||||
|
qreal min[2], max[2];
|
||||||
|
min[0] = trect.left();
|
||||||
|
min[1] = trect.top();
|
||||||
|
max[0] = trect.right();
|
||||||
|
max[1] = trect.bottom();
|
||||||
|
z.tree.Insert(min, max, &tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNXMap::JNXMap(const QString &fileName, QObject *parent)
|
||||||
|
: Map(parent), _file(fileName), _zoom(0), _valid(false)
|
||||||
|
{
|
||||||
|
_name = QFileInfo(fileName).fileName();
|
||||||
|
|
||||||
|
if (!_file.open(QIODevice::ReadOnly)) {
|
||||||
|
_errorString = QString("%1: Error opening file").arg(fileName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!readTiles()) {
|
||||||
|
_errorString = "JNX file format error";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF JNXMap::ll2xy(const Coordinates &c)
|
||||||
|
{
|
||||||
|
const Transform &t = _zooms.at(_zoom).transform;
|
||||||
|
return t.proj2img(PointD(c.lon(), c.lat()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates JNXMap::xy2ll(const QPointF &p)
|
||||||
|
{
|
||||||
|
const Transform &t = _zooms.at(_zoom).transform;
|
||||||
|
PointD pp(t.img2proj(p));
|
||||||
|
return Coordinates(pp.x(), pp.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF JNXMap::bounds() const
|
||||||
|
{
|
||||||
|
const Transform &t = _zooms.at(_zoom).transform;
|
||||||
|
|
||||||
|
return QRectF(t.proj2img(PointD(_bounds.topLeft().lon(),
|
||||||
|
_bounds.topLeft().lat())), t.proj2img(PointD(_bounds.bottomRight().lon(),
|
||||||
|
_bounds.bottomRight().lat())));
|
||||||
|
}
|
||||||
|
|
||||||
|
int JNXMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
|
{
|
||||||
|
if (!rect.isValid())
|
||||||
|
_zoom = _zooms.size() - 1;
|
||||||
|
else {
|
||||||
|
for (int i = 1; i < _zooms.count(); i++) {
|
||||||
|
_zoom = i;
|
||||||
|
QRect sbr(QPoint(ll2xy(rect.topLeft()).toPoint()),
|
||||||
|
QPoint(ll2xy(rect.bottomRight()).toPoint()));
|
||||||
|
if (sbr.size().width() >= size.width() || sbr.size().height()
|
||||||
|
>= size.height()) {
|
||||||
|
_zoom--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
int JNXMap::zoomIn()
|
||||||
|
{
|
||||||
|
_zoom = qMin(_zoom + 1, _zooms.size() - 1);
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
int JNXMap::zoomOut()
|
||||||
|
{
|
||||||
|
_zoom = qMax(_zoom - 1, 0);
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap JNXMap::pixmap(const Tile *tile, QFile *file)
|
||||||
|
{
|
||||||
|
QPixmap pm;
|
||||||
|
|
||||||
|
QString key = file->fileName() + "-" + QString::number(tile->offset);
|
||||||
|
if (!QPixmapCache::find(key, &pm)) {
|
||||||
|
QByteArray ba;
|
||||||
|
ba.resize(tile->size + 2);
|
||||||
|
ba[0] = (char)0xFF;
|
||||||
|
ba[1] = (char)0xD8;
|
||||||
|
char *data = ba.data() + 2;
|
||||||
|
|
||||||
|
if (!file->seek(tile->offset))
|
||||||
|
return QPixmap();
|
||||||
|
if (!file->read(data, tile->size))
|
||||||
|
return QPixmap();
|
||||||
|
pm = QPixmap::fromImage(QImage::fromData(ba));
|
||||||
|
|
||||||
|
if (!pm.isNull())
|
||||||
|
QPixmapCache::insert(key, pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pm;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JNXMap::cb(Tile *tile, void *context)
|
||||||
|
{
|
||||||
|
Ctx *ctx = static_cast<Ctx*>(context);
|
||||||
|
ctx->painter->drawPixmap(tile->pos, pixmap(tile, ctx->file));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JNXMap::draw(QPainter *painter, const QRectF &rect, bool block)
|
||||||
|
{
|
||||||
|
Q_UNUSED(block);
|
||||||
|
const RTree<Tile*, qreal, 2> &tree = _zooms.at(_zoom).tree;
|
||||||
|
Ctx ctx(painter, &_file);
|
||||||
|
|
||||||
|
qreal min[2], max[2];
|
||||||
|
min[0] = rect.left();
|
||||||
|
min[1] = rect.top();
|
||||||
|
max[0] = rect.right();
|
||||||
|
max[1] = rect.bottom();
|
||||||
|
tree.Search(min, max, cb, &ctx);
|
||||||
|
}
|
67
src/map/jnxmap.h
Normal file
67
src/map/jnxmap.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#ifndef JNXMAP_H
|
||||||
|
#define JNXMAP_H
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QVector>
|
||||||
|
#include "common/rtree.h"
|
||||||
|
#include "common/rectc.h"
|
||||||
|
#include "transform.h"
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
|
class JNXMap : public Map
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
JNXMap(const QString &fileName, QObject *parent = 0);
|
||||||
|
|
||||||
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
|
QRectF bounds() const;
|
||||||
|
|
||||||
|
int zoom() const {return _zoom;}
|
||||||
|
void setZoom(int zoom) {_zoom = zoom;}
|
||||||
|
int zoomFit(const QSize &size, const RectC &rect);
|
||||||
|
int zoomIn();
|
||||||
|
int zoomOut();
|
||||||
|
|
||||||
|
QPointF ll2xy(const Coordinates &c);
|
||||||
|
Coordinates xy2ll(const QPointF &p);
|
||||||
|
|
||||||
|
void draw(QPainter *painter, const QRectF &rect, bool block);
|
||||||
|
|
||||||
|
bool isValid() const {return _valid;}
|
||||||
|
QString errorString() const {return _errorString;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Tile {
|
||||||
|
QPointF pos;
|
||||||
|
quint32 size;
|
||||||
|
quint32 offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Zoom {
|
||||||
|
Transform transform;
|
||||||
|
QVector<Tile> tiles;
|
||||||
|
RTree<Tile*, qreal, 2> tree;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T> bool readValue(T &val);
|
||||||
|
bool readString(QByteArray &ba);
|
||||||
|
bool readTiles();
|
||||||
|
|
||||||
|
static bool cb(Tile *tile, void *context);
|
||||||
|
static QPixmap pixmap(const Tile *tile, QFile *file);
|
||||||
|
|
||||||
|
QString _name;
|
||||||
|
QFile _file;
|
||||||
|
QVector<Zoom> _zooms;
|
||||||
|
int _zoom;
|
||||||
|
RectC _bounds;
|
||||||
|
|
||||||
|
bool _valid;
|
||||||
|
QString _errorString;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // JNXMAP_H
|
70
src/map/krovak.cpp
Normal file
70
src/map/krovak.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#include "ellipsoid.h"
|
||||||
|
#include "krovak.h"
|
||||||
|
|
||||||
|
Krovak::Krovak(const Ellipsoid *ellipsoid, double standardParallel,
|
||||||
|
double azimuth, double scale, double centerLatitude, double longitudeOrigin,
|
||||||
|
double falseEasting, double falseNorthing)
|
||||||
|
{
|
||||||
|
double phiC = deg2rad(centerLatitude);
|
||||||
|
double sinPhiC = sin(phiC);
|
||||||
|
double sinPhiC2 = sinPhiC * sinPhiC;
|
||||||
|
double cosPhiC = cos(phiC);
|
||||||
|
double cosPhiC2 = cosPhiC * cosPhiC;
|
||||||
|
double cosPhiC4 = cosPhiC2 * cosPhiC2;
|
||||||
|
double alphaC = deg2rad(azimuth);
|
||||||
|
|
||||||
|
_phiP = deg2rad(standardParallel);
|
||||||
|
_e = sqrt(ellipsoid->es());
|
||||||
|
_A = ellipsoid->radius() * sqrt(1.0 - ellipsoid->es())
|
||||||
|
/ (1.0 - ellipsoid->es() * sinPhiC2);
|
||||||
|
_B = sqrt(1.0 + (ellipsoid->es() * cosPhiC4 / (1.0 - ellipsoid->es())));
|
||||||
|
double gamma0 = asin(sinPhiC / _B);
|
||||||
|
_t0 = tan(M_PI_4 + gamma0 / 2.0) * pow((1.0 + _e * sinPhiC) /
|
||||||
|
(1.0 - _e * sinPhiC), _e*_B / 2.0) / pow(tan(M_PI_4 + phiC/2.0), _B);
|
||||||
|
_n = sin(_phiP);
|
||||||
|
_r0 = scale * _A / tan(_phiP);
|
||||||
|
_FE = falseEasting;
|
||||||
|
_FN = falseNorthing;
|
||||||
|
_cosAlphaC = cos(alphaC);
|
||||||
|
_sinAlphaC = sin(alphaC);
|
||||||
|
_lambda0 = deg2rad(longitudeOrigin);
|
||||||
|
}
|
||||||
|
|
||||||
|
PointD Krovak::ll2xy(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
double phi = deg2rad(c.lat());
|
||||||
|
double lambda = deg2rad(c.lon());
|
||||||
|
double eSinPhi = _e * sin(phi);
|
||||||
|
double U = 2.0 * (atan(_t0 * pow(tan(phi/2.0 + M_PI_4), _B)
|
||||||
|
/ pow((1.0 + eSinPhi) / (1.0 - eSinPhi), _e * _B/2.0)) - M_PI_4);
|
||||||
|
double cosU = cos(U);
|
||||||
|
double V = _B * (_lambda0 - lambda);
|
||||||
|
double T = asin(_cosAlphaC * sin(U) + _sinAlphaC * cosU * cos(V));
|
||||||
|
double D = asin(cosU * sin(V) / cos(T));
|
||||||
|
double theta = _n * D;
|
||||||
|
double r = _r0 * pow(tan(M_PI_4 + _phiP/2.0), _n)
|
||||||
|
/ pow(tan(T/2.0 + M_PI_4), _n);
|
||||||
|
|
||||||
|
return PointD(r * sin(theta) + _FE, r * cos(theta) + _FN);
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates Krovak::xy2ll(const PointD &p) const
|
||||||
|
{
|
||||||
|
double Xp = p.y() - _FN;
|
||||||
|
double Yp = p.x() - _FE;
|
||||||
|
double Xp2 = Xp * Xp;
|
||||||
|
double Yp2 = Yp * Yp;
|
||||||
|
double r = sqrt(Xp2 + Yp2);
|
||||||
|
double theta = atan(Yp / Xp);
|
||||||
|
double D = theta / sin(_phiP);
|
||||||
|
double T = 2.0 * (atan(pow(_r0 / r, 1.0/_n) * tan(M_PI_4 + _phiP/2.0))
|
||||||
|
- M_PI_4);
|
||||||
|
double U = asin(_cosAlphaC * sin(T) - _sinAlphaC * cos(T) * cos(D));
|
||||||
|
double V = asin(cos(T) * sin(D) / cos(U));
|
||||||
|
double phi = U;
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
phi = 2.0 * (atan(pow(_t0, -1.0/_B) * pow(tan(U/2.0 + M_PI_4), 1.0/_B)
|
||||||
|
* pow((1.0 + _e * sin(phi))/(1.0 - _e * sin(phi)), _e/2.0)) - M_PI_4);
|
||||||
|
|
||||||
|
return Coordinates(rad2deg(_lambda0 - V/_B), rad2deg(phi));
|
||||||
|
}
|
45
src/map/krovak.h
Normal file
45
src/map/krovak.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#ifndef KROVAK_H
|
||||||
|
#define KROVAK_H
|
||||||
|
|
||||||
|
#include "ct.h"
|
||||||
|
|
||||||
|
class Ellipsoid;
|
||||||
|
|
||||||
|
class Krovak : public CT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Krovak(const Ellipsoid *ellipsoid, double standardParallel,
|
||||||
|
double azimuth, double scale, double centerLatitude,
|
||||||
|
double longitudeOrigin, double falseEasting, double falseNorthing);
|
||||||
|
|
||||||
|
virtual CT *clone() const {return new Krovak(*this);}
|
||||||
|
|
||||||
|
virtual PointD ll2xy(const Coordinates &c) const;
|
||||||
|
virtual Coordinates xy2ll(const PointD &p) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
double _e, _A, _B, _t0, _n, _r0, _phiP;
|
||||||
|
double _cosAlphaC, _sinAlphaC, _lambda0, _FE, _FN;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KrovakNE : public CT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KrovakNE(const Ellipsoid *ellipsoid, double standardParallel,
|
||||||
|
double azimuth, double scale, double centerLatitude,
|
||||||
|
double longitudeOrigin, double falseEasting, double falseNorthing)
|
||||||
|
: _k(ellipsoid, standardParallel, azimuth, scale, centerLatitude,
|
||||||
|
longitudeOrigin, falseEasting, falseNorthing) {}
|
||||||
|
|
||||||
|
virtual CT *clone() const {return new KrovakNE(*this);}
|
||||||
|
|
||||||
|
virtual PointD ll2xy(const Coordinates &c) const
|
||||||
|
{PointD p(_k.ll2xy(c)); return PointD(-p.x(), -p.y());}
|
||||||
|
virtual Coordinates xy2ll(const PointD &p) const
|
||||||
|
{return _k.xy2ll(PointD(-p.x(), -p.y()));}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Krovak _k;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // KROVAK_H
|
@ -16,19 +16,17 @@ LambertAzimuthal::LambertAzimuthal(const Ellipsoid *ellipsoid,
|
|||||||
_lon0 = deg2rad(longitudeOrigin);
|
_lon0 = deg2rad(longitudeOrigin);
|
||||||
|
|
||||||
_a = ellipsoid->radius();
|
_a = ellipsoid->radius();
|
||||||
|
_es = ellipsoid->es();
|
||||||
|
_e = sqrt(_es);
|
||||||
|
|
||||||
_es2 = 2.0 * ellipsoid->flattening() - ellipsoid->flattening()
|
double q0 = (1.0 - _es) * ((sin(lat0) / (1.0 - _es * sin2(lat0)))
|
||||||
* ellipsoid->flattening();
|
- ((1.0/(2.0*_e)) * log((1.0 - _e * sin(lat0)) / (1.0 + _e
|
||||||
_es = sqrt(_es2);
|
|
||||||
|
|
||||||
double q0 = (1.0 - _es2) * ((sin(lat0) / (1.0 - _es2 * sin2(lat0)))
|
|
||||||
- ((1.0/(2.0*_es)) * log((1.0 - _es * sin(lat0)) / (1.0 + _es
|
|
||||||
* sin(lat0)))));
|
* sin(lat0)))));
|
||||||
_qP = (1.0 - _es2) * ((1.0 / (1.0 - _es2)) - ((1.0/(2.0*_es))
|
_qP = (1.0 - _es) * ((1.0 / (1.0 - _es)) - ((1.0/(2.0*_e))
|
||||||
* log((1.0 - _es) / (1.0 + _es))));
|
* log((1.0 - _e) / (1.0 + _e))));
|
||||||
_beta0 = asin(q0 / _qP);
|
_beta0 = asin(q0 / _qP);
|
||||||
_Rq = _a * sqrt(_qP / 2.0);
|
_Rq = _a * sqrt(_qP / 2.0);
|
||||||
_D = _a * (cos(lat0) / sqrt(1.0 - _es2 * sin2(lat0))) / (_Rq * cos(_beta0));
|
_D = _a * (cos(lat0) / sqrt(1.0 - _es * sin2(lat0))) / (_Rq * cos(_beta0));
|
||||||
}
|
}
|
||||||
|
|
||||||
PointD LambertAzimuthal::ll2xy(const Coordinates &c) const
|
PointD LambertAzimuthal::ll2xy(const Coordinates &c) const
|
||||||
@ -36,8 +34,8 @@ PointD LambertAzimuthal::ll2xy(const Coordinates &c) const
|
|||||||
double lon = deg2rad(c.lon());
|
double lon = deg2rad(c.lon());
|
||||||
double lat = deg2rad(c.lat());
|
double lat = deg2rad(c.lat());
|
||||||
|
|
||||||
double q = (1.0 - _es2) * ((sin(lat) / (1.0 - _es2 * sin2(lat)))
|
double q = (1.0 - _es) * ((sin(lat) / (1.0 - _es * sin2(lat)))
|
||||||
- ((1.0/(2.0*_es)) * log((1.0 - _es * sin(lat)) / (1.0 + _es
|
- ((1.0/(2.0*_e)) * log((1.0 - _e * sin(lat)) / (1.0 + _e
|
||||||
* sin(lat)))));
|
* sin(lat)))));
|
||||||
double beta = asin(q / _qP);
|
double beta = asin(q / _qP);
|
||||||
double B = _Rq * sqrt(2.0 / (1.0 + sin(_beta0) * sin(beta) + (cos(_beta0)
|
double B = _Rq * sqrt(2.0 / (1.0 + sin(_beta0) * sin(beta) + (cos(_beta0)
|
||||||
@ -52,8 +50,8 @@ PointD LambertAzimuthal::ll2xy(const Coordinates &c) const
|
|||||||
|
|
||||||
Coordinates LambertAzimuthal::xy2ll(const PointD &p) const
|
Coordinates LambertAzimuthal::xy2ll(const PointD &p) const
|
||||||
{
|
{
|
||||||
double es4 = _es2 * _es2;
|
double es4 = _es * _es;
|
||||||
double es6 = _es2 * es4;
|
double es6 = _es * es4;
|
||||||
|
|
||||||
double rho = sqrt(sqr((p.x() - _falseEasting) / _D) + sqr(_D * (p.y()
|
double rho = sqrt(sqr((p.x() - _falseEasting) / _D) + sqr(_D * (p.y()
|
||||||
- _falseNorthing)));
|
- _falseNorthing)));
|
||||||
@ -64,7 +62,7 @@ Coordinates LambertAzimuthal::xy2ll(const PointD &p) const
|
|||||||
double lon = _lon0 + atan((p.x() - _falseEasting) * sin(C) / (_D * rho
|
double lon = _lon0 + atan((p.x() - _falseEasting) * sin(C) / (_D * rho
|
||||||
* cos(_beta0) * cos(C) - sqr(_D) * (p.y() - _falseNorthing) * sin(_beta0)
|
* cos(_beta0) * cos(C) - sqr(_D) * (p.y() - _falseNorthing) * sin(_beta0)
|
||||||
* sin(C)));
|
* sin(C)));
|
||||||
double lat = betaS + ((_es2/3.0 + 31.0*es4/180.0 + 517.0*es6/5040.0)
|
double lat = betaS + ((_es/3.0 + 31.0*es4/180.0 + 517.0*es6/5040.0)
|
||||||
* sin(2.0*betaS)) + ((23.0*es4/360.0 + 251.0*es6/3780.0) * sin(4.0*betaS))
|
* sin(2.0*betaS)) + ((23.0*es4/360.0 + 251.0*es6/3780.0) * sin(4.0*betaS))
|
||||||
+ ((761.0*es6/45360.0)*sin(6.0*betaS));
|
+ ((761.0*es6/45360.0)*sin(6.0*betaS));
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ private:
|
|||||||
double _lon0;
|
double _lon0;
|
||||||
double _falseNorthing;
|
double _falseNorthing;
|
||||||
double _falseEasting;
|
double _falseEasting;
|
||||||
double _a, _es, _es2, _qP, _beta0, _Rq, _D;
|
double _a, _e, _es, _qP, _beta0, _Rq, _D;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAMBERTAZIMUTHAL_H
|
#endif // LAMBERTAZIMUTHAL_H
|
||||||
|
@ -45,12 +45,6 @@ Defense.
|
|||||||
#include "ellipsoid.h"
|
#include "ellipsoid.h"
|
||||||
#include "lambertconic.h"
|
#include "lambertconic.h"
|
||||||
|
|
||||||
#ifndef M_PI_2
|
|
||||||
#define M_PI_2 1.57079632679489661923
|
|
||||||
#endif // M_PI_2
|
|
||||||
#ifndef M_PI_4
|
|
||||||
#define M_PI_4 0.785398163397448309616
|
|
||||||
#endif /* M_PI_4 */
|
|
||||||
|
|
||||||
#define LAMBERT_m(clat, essin) (clat / sqrt(1.0 - essin * essin))
|
#define LAMBERT_m(clat, essin) (clat / sqrt(1.0 - essin * essin))
|
||||||
#define LAMBERT2_t(lat, essin, es_over_2) \
|
#define LAMBERT2_t(lat, essin, es_over_2) \
|
||||||
@ -63,8 +57,7 @@ LambertConic1::LambertConic1(const Ellipsoid *ellipsoid, double latitudeOrigin,
|
|||||||
double longitudeOrigin, double scale, double falseEasting,
|
double longitudeOrigin, double scale, double falseEasting,
|
||||||
double falseNorthing)
|
double falseNorthing)
|
||||||
{
|
{
|
||||||
double es2;
|
double e_sin;
|
||||||
double es_sin;
|
|
||||||
double m0;
|
double m0;
|
||||||
double lat_orig;
|
double lat_orig;
|
||||||
|
|
||||||
@ -72,21 +65,19 @@ LambertConic1::LambertConic1(const Ellipsoid *ellipsoid, double latitudeOrigin,
|
|||||||
lat_orig = deg2rad(latitudeOrigin);
|
lat_orig = deg2rad(latitudeOrigin);
|
||||||
_longitudeOrigin = deg2rad(longitudeOrigin);
|
_longitudeOrigin = deg2rad(longitudeOrigin);
|
||||||
if (_longitudeOrigin > M_PI)
|
if (_longitudeOrigin > M_PI)
|
||||||
_longitudeOrigin -= 2 * M_PI;
|
_longitudeOrigin -= M_2_PI;
|
||||||
|
|
||||||
_falseEasting = falseEasting;
|
_falseEasting = falseEasting;
|
||||||
_falseNorthing = falseNorthing;
|
_falseNorthing = falseNorthing;
|
||||||
|
|
||||||
es2 = 2.0 * ellipsoid->flattening() - ellipsoid->flattening()
|
_e = sqrt(ellipsoid->es());
|
||||||
* ellipsoid->flattening();
|
_e_over_2 = _e / 2.0;
|
||||||
_es = sqrt(es2);
|
|
||||||
_es_over_2 = _es / 2.0;
|
|
||||||
|
|
||||||
_n = sin(lat_orig);
|
_n = sin(lat_orig);
|
||||||
|
|
||||||
es_sin = _es * sin(lat_orig);
|
e_sin = _e * sin(lat_orig);
|
||||||
m0 = LAMBERT_m(cos(lat_orig), es_sin);
|
m0 = LAMBERT_m(cos(lat_orig), e_sin);
|
||||||
_t0 = LAMBERT1_t(lat_orig, es_sin, _es_over_2);
|
_t0 = LAMBERT1_t(lat_orig, e_sin, _e_over_2);
|
||||||
|
|
||||||
_rho0 = ellipsoid->radius() * scale * m0 / _n;
|
_rho0 = ellipsoid->radius() * scale * m0 / _n;
|
||||||
|
|
||||||
@ -103,7 +94,7 @@ PointD LambertConic1::ll2xy(const Coordinates &c) const
|
|||||||
|
|
||||||
|
|
||||||
if (fabs(fabs(lat) - M_PI_2) > 1.0e-10) {
|
if (fabs(fabs(lat) - M_PI_2) > 1.0e-10) {
|
||||||
t = LAMBERT1_t(lat, _es * sin(lat), _es_over_2);
|
t = LAMBERT1_t(lat, _e * sin(lat), _e_over_2);
|
||||||
rho = _rho0 * pow(t / _t0, _n);
|
rho = _rho0 * pow(t / _t0, _n);
|
||||||
} else
|
} else
|
||||||
rho = 0.0;
|
rho = 0.0;
|
||||||
@ -111,9 +102,9 @@ PointD LambertConic1::ll2xy(const Coordinates &c) const
|
|||||||
dlam = deg2rad(c.lon()) - _longitudeOrigin;
|
dlam = deg2rad(c.lon()) - _longitudeOrigin;
|
||||||
|
|
||||||
if (dlam > M_PI)
|
if (dlam > M_PI)
|
||||||
dlam -= 2 * M_PI;
|
dlam -= M_2_PI;
|
||||||
if (dlam < -M_PI)
|
if (dlam < -M_PI)
|
||||||
dlam += 2 * M_PI;
|
dlam += M_2_PI;
|
||||||
|
|
||||||
theta = _n * dlam;
|
theta = _n * dlam;
|
||||||
|
|
||||||
@ -154,9 +145,9 @@ Coordinates LambertConic1::xy2ll(const PointD &p) const
|
|||||||
PHI = M_PI_2 - 2.0 * atan(t);
|
PHI = M_PI_2 - 2.0 * atan(t);
|
||||||
while (fabs(PHI - tempPHI) > tolerance && count) {
|
while (fabs(PHI - tempPHI) > tolerance && count) {
|
||||||
tempPHI = PHI;
|
tempPHI = PHI;
|
||||||
es_sin = _es * sin(PHI);
|
es_sin = _e * sin(PHI);
|
||||||
PHI = M_PI_2 - 2.0 * atan(t * pow((1.0 - es_sin) / (1.0 + es_sin),
|
PHI = M_PI_2 - 2.0 * atan(t * pow((1.0 - es_sin) / (1.0 + es_sin),
|
||||||
_es_over_2));
|
_e_over_2));
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,13 +168,13 @@ Coordinates LambertConic1::xy2ll(const PointD &p) const
|
|||||||
if (lon - M_PI < 3.5e-6)
|
if (lon - M_PI < 3.5e-6)
|
||||||
lon = M_PI;
|
lon = M_PI;
|
||||||
else
|
else
|
||||||
lon -= 2 * M_PI;
|
lon -= M_2_PI;
|
||||||
}
|
}
|
||||||
if (lon < -M_PI) {
|
if (lon < -M_PI) {
|
||||||
if (fabs(lon + M_PI) < 3.5e-6)
|
if (fabs(lon + M_PI) < 3.5e-6)
|
||||||
lon = -M_PI;
|
lon = -M_PI;
|
||||||
else
|
else
|
||||||
lon += 2 * M_PI;
|
lon += M_2_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fabs(lon) < 2.0e-7)
|
if (fabs(lon) < 2.0e-7)
|
||||||
@ -207,7 +198,7 @@ LambertConic2::LambertConic2(const Ellipsoid *ellipsoid,
|
|||||||
double standardParallel1, double standardParallel2, double latitudeOrigin,
|
double standardParallel1, double standardParallel2, double latitudeOrigin,
|
||||||
double longitudeOrigin, double falseEasting, double falseNorthing)
|
double longitudeOrigin, double falseEasting, double falseNorthing)
|
||||||
{
|
{
|
||||||
double es, es_over_2, es2, es_sin;
|
double e, e_over_2, e_sin;
|
||||||
double lat0;
|
double lat0;
|
||||||
double k0;
|
double k0;
|
||||||
double t0;
|
double t0;
|
||||||
@ -227,29 +218,27 @@ LambertConic2::LambertConic2(const Ellipsoid *ellipsoid,
|
|||||||
sp2 = deg2rad(standardParallel2);
|
sp2 = deg2rad(standardParallel2);
|
||||||
|
|
||||||
if (fabs(sp1 - sp2) > 1.0e-10) {
|
if (fabs(sp1 - sp2) > 1.0e-10) {
|
||||||
es2 = 2 * ellipsoid->flattening() - ellipsoid->flattening()
|
e = sqrt(ellipsoid->es());
|
||||||
* ellipsoid->flattening();
|
e_over_2 = e / 2.0;
|
||||||
es = sqrt(es2);
|
|
||||||
es_over_2 = es / 2.0;
|
|
||||||
|
|
||||||
es_sin = es * sin(lat_orig);
|
e_sin = e * sin(lat_orig);
|
||||||
t_olat = LAMBERT2_t(lat_orig, es_sin, es_over_2);
|
t_olat = LAMBERT2_t(lat_orig, e_sin, e_over_2);
|
||||||
|
|
||||||
es_sin = es * sin(sp1);
|
e_sin = e * sin(sp1);
|
||||||
m1 = LAMBERT_m(cos(sp1), es_sin);
|
m1 = LAMBERT_m(cos(sp1), e_sin);
|
||||||
t1 = LAMBERT2_t(sp1, es_sin, es_over_2);
|
t1 = LAMBERT2_t(sp1, e_sin, e_over_2);
|
||||||
|
|
||||||
es_sin = es * sin(sp2);
|
e_sin = e * sin(sp2);
|
||||||
m2 = LAMBERT_m(cos(sp2), es_sin);
|
m2 = LAMBERT_m(cos(sp2), e_sin);
|
||||||
t2 = LAMBERT2_t(sp2, es_sin, es_over_2);
|
t2 = LAMBERT2_t(sp2, e_sin, e_over_2);
|
||||||
|
|
||||||
n = log(m1 / m2) / log(t1 / t2);
|
n = log(m1 / m2) / log(t1 / t2);
|
||||||
|
|
||||||
lat0 = asin(n);
|
lat0 = asin(n);
|
||||||
|
|
||||||
es_sin = es * sin(lat0);
|
e_sin = e * sin(lat0);
|
||||||
m0 = LAMBERT_m(cos(lat0), es_sin);
|
m0 = LAMBERT_m(cos(lat0), e_sin);
|
||||||
t0 = LAMBERT2_t(lat0, es_sin, es_over_2);
|
t0 = LAMBERT2_t(lat0, e_sin, e_over_2);
|
||||||
|
|
||||||
k0 = (m1 / m0) * (pow(t0 / t1, n));
|
k0 = (m1 / m0) * (pow(t0 / t1, n));
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ private:
|
|||||||
double _falseEasting;
|
double _falseEasting;
|
||||||
double _falseNorthing;
|
double _falseNorthing;
|
||||||
|
|
||||||
double _es;
|
double _e;
|
||||||
double _es_over_2;
|
double _e_over_2;
|
||||||
double _n;
|
double _n;
|
||||||
double _t0;
|
double _t0;
|
||||||
double _rho0;
|
double _rho0;
|
||||||
|
@ -15,6 +15,15 @@ LinearUnits::LinearUnits(int code)
|
|||||||
case 9040:
|
case 9040:
|
||||||
_f = 36.0 / 39.370147;
|
_f = 36.0 / 39.370147;
|
||||||
break;
|
break;
|
||||||
|
case 9041:
|
||||||
|
_f = 12.0 / 39.370147;
|
||||||
|
break;
|
||||||
|
case 9042:
|
||||||
|
_f = 792.0 / 39.370147;
|
||||||
|
break;
|
||||||
|
case 9094:
|
||||||
|
_f = 6378300.0 / 20926201.0;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
_f = NAN;
|
_f = NAN;
|
||||||
}
|
}
|
||||||
|
14
src/map/map.cpp
Normal file
14
src/map/map.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <QLineF>
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
|
qreal Map::resolution(const QRectF &rect)
|
||||||
|
{
|
||||||
|
qreal cy = rect.center().y();
|
||||||
|
QPointF cl(rect.left(), cy);
|
||||||
|
QPointF cr(rect.right(), cy);
|
||||||
|
|
||||||
|
qreal ds = xy2ll(cl).distanceTo(xy2ll(cr));
|
||||||
|
qreal ps = QLineF(cl, cr).length();
|
||||||
|
|
||||||
|
return ds/ps;
|
||||||
|
}
|
@ -15,13 +15,13 @@ class Map : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Map(QObject *parent = 0) : QObject(parent), _backgroundColor(Qt::white) {}
|
Map(QObject *parent = 0) : QObject(parent) {}
|
||||||
virtual ~Map() {}
|
virtual ~Map() {}
|
||||||
|
|
||||||
virtual const QString &name() const = 0;
|
virtual const QString &name() const = 0;
|
||||||
|
|
||||||
virtual QRectF bounds() const = 0;
|
virtual QRectF bounds() const = 0;
|
||||||
virtual qreal resolution(const QRectF &rect) const = 0;
|
virtual qreal resolution(const QRectF &rect);
|
||||||
|
|
||||||
virtual int zoom() const = 0;
|
virtual int zoom() const = 0;
|
||||||
virtual void setZoom(int zoom) = 0;
|
virtual void setZoom(int zoom) = 0;
|
||||||
@ -41,13 +41,8 @@ public:
|
|||||||
virtual bool isValid() const {return true;}
|
virtual bool isValid() const {return true;}
|
||||||
virtual QString errorString() const {return QString();}
|
virtual QString errorString() const {return QString();}
|
||||||
|
|
||||||
void setBackgroundColor(const QColor &color) {_backgroundColor = color;}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loaded();
|
void loaded();
|
||||||
|
|
||||||
protected:
|
|
||||||
QColor _backgroundColor;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAP_H
|
#endif // MAP_H
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
#include "mapfile.h"
|
#include "mapfile.h"
|
||||||
|
|
||||||
|
|
||||||
static double parameter(const QString &str, bool *res)
|
static double parameter(const QString &str, bool *res, double def = 0.0)
|
||||||
{
|
{
|
||||||
QString field = str.trimmed();
|
QString field = str.trimmed();
|
||||||
if (field.isEmpty()) {
|
if (field.isEmpty()) {
|
||||||
*res = true;
|
*res = true;
|
||||||
return NAN;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
return field.toDouble(res);
|
return field.toDouble(res);
|
||||||
@ -26,7 +26,8 @@ int MapFile::parse(QIODevice &device, QList<CalibrationPoint> &points,
|
|||||||
QByteArray line = device.readLine();
|
QByteArray line = device.readLine();
|
||||||
|
|
||||||
if (ln == 1) {
|
if (ln == 1) {
|
||||||
if (!line.trimmed().startsWith("OziExplorer Map Data File"))
|
QString fileType(QString::fromUtf8(line).trimmed());
|
||||||
|
if (!fileType.startsWith("OziExplorer Map Data File"))
|
||||||
return ln;
|
return ln;
|
||||||
} else if (ln == 2)
|
} else if (ln == 2)
|
||||||
_name = line.trimmed();
|
_name = line.trimmed();
|
||||||
@ -116,7 +117,7 @@ int MapFile::parse(QIODevice &device, QList<CalibrationPoint> &points,
|
|||||||
|
|
||||||
setup = Projection::Setup(
|
setup = Projection::Setup(
|
||||||
parameter(list[1], &r[1]), parameter(list[2], &r[2]),
|
parameter(list[1], &r[1]), parameter(list[2], &r[2]),
|
||||||
parameter(list[3], &r[3]), parameter(list[4], &r[4]),
|
parameter(list[3], &r[3], 1.0), parameter(list[4], &r[4]),
|
||||||
parameter(list[5], &r[5]), parameter(list[6], &r[6]),
|
parameter(list[5], &r[5]), parameter(list[6], &r[6]),
|
||||||
parameter(list[7], &r[7]));
|
parameter(list[7], &r[7]));
|
||||||
|
|
||||||
|
@ -3,33 +3,13 @@
|
|||||||
#include "atlas.h"
|
#include "atlas.h"
|
||||||
#include "offlinemap.h"
|
#include "offlinemap.h"
|
||||||
#include "onlinemap.h"
|
#include "onlinemap.h"
|
||||||
|
#include "jnxmap.h"
|
||||||
#include "mapsource.h"
|
#include "mapsource.h"
|
||||||
#include "maplist.h"
|
#include "maplist.h"
|
||||||
|
|
||||||
|
|
||||||
bool MapList::loadSource(const QString &path, bool dir)
|
bool MapList::loadMap(Map* map, const QString &path, bool dir)
|
||||||
{
|
{
|
||||||
MapSource ms;
|
|
||||||
Map *map;
|
|
||||||
|
|
||||||
if (!(map = ms.loadFile(path))) {
|
|
||||||
if (dir)
|
|
||||||
_errorString += path + ": " + ms.errorString() + "\n";
|
|
||||||
else
|
|
||||||
_errorString = ms.errorString();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
map->setParent(this);
|
|
||||||
_maps.append(map);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MapList::loadMap(const QString &path, bool dir)
|
|
||||||
{
|
|
||||||
OfflineMap *map = new OfflineMap(path, this);
|
|
||||||
|
|
||||||
if (map->isValid()) {
|
if (map->isValid()) {
|
||||||
_maps.append(map);
|
_maps.append(map);
|
||||||
return true;
|
return true;
|
||||||
@ -38,26 +18,27 @@ bool MapList::loadMap(const QString &path, bool dir)
|
|||||||
_errorString += path + ": " + map->errorString() + "\n";
|
_errorString += path + ": " + map->errorString() + "\n";
|
||||||
else
|
else
|
||||||
_errorString = map->errorString();
|
_errorString = map->errorString();
|
||||||
|
|
||||||
delete map;
|
delete map;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapList::loadAtlas(const QString &path, bool dir)
|
bool MapList::loadSource(const QString &path, bool dir)
|
||||||
{
|
{
|
||||||
Atlas *atlas = new Atlas(path, this);
|
QString err;
|
||||||
|
Map *map = MapSource::loadMap(path, err);
|
||||||
|
|
||||||
if (atlas->isValid()) {
|
if (!map) {
|
||||||
_maps.append(atlas);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (dir)
|
if (dir)
|
||||||
_errorString += path + ": " + atlas->errorString() + "\n";
|
_errorString += path + ": " + err + "\n";
|
||||||
else
|
else
|
||||||
_errorString = atlas->errorString();
|
_errorString = err;
|
||||||
delete atlas;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
map->setParent(this);
|
||||||
|
|
||||||
|
return loadMap(map, path, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapList::loadFile(const QString &path, bool *atlas, bool dir)
|
bool MapList::loadFile(const QString &path, bool *atlas, bool dir)
|
||||||
@ -67,14 +48,13 @@ bool MapList::loadFile(const QString &path, bool *atlas, bool dir)
|
|||||||
|
|
||||||
if (Atlas::isAtlas(path)) {
|
if (Atlas::isAtlas(path)) {
|
||||||
*atlas = true;
|
*atlas = true;
|
||||||
return loadAtlas(path, dir);
|
return loadMap(new Atlas(path, this), path, dir);
|
||||||
} else if (suffix == "xml") {
|
} else if (suffix == "xml")
|
||||||
*atlas = false;
|
|
||||||
return loadSource(path, dir);
|
return loadSource(path, dir);
|
||||||
} else {
|
else if (suffix == "jnx")
|
||||||
*atlas = false;
|
return loadMap(new JNXMap(path, this), path, dir);
|
||||||
return loadMap(path, dir);
|
else
|
||||||
}
|
return loadMap(new OfflineMap(path, this), path, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapList::loadDirR(const QString &path)
|
bool MapList::loadDirR(const QString &path)
|
||||||
@ -83,11 +63,12 @@ bool MapList::loadDirR(const QString &path)
|
|||||||
md.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
md.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
md.setSorting(QDir::DirsLast);
|
md.setSorting(QDir::DirsLast);
|
||||||
QFileInfoList ml = md.entryInfoList();
|
QFileInfoList ml = md.entryInfoList();
|
||||||
bool atlas, ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
for (int i = 0; i < ml.size(); i++) {
|
for (int i = 0; i < ml.size(); i++) {
|
||||||
const QFileInfo &fi = ml.at(i);
|
const QFileInfo &fi = ml.at(i);
|
||||||
QString suffix = fi.suffix().toLower();
|
QString suffix = fi.suffix().toLower();
|
||||||
|
bool atlas = false;
|
||||||
|
|
||||||
if (fi.isDir() && fi.fileName() != "set") {
|
if (fi.isDir() && fi.fileName() != "set") {
|
||||||
if (!loadDirR(fi.absoluteFilePath()))
|
if (!loadDirR(fi.absoluteFilePath()))
|
||||||
@ -127,7 +108,8 @@ void MapList::clear()
|
|||||||
QString MapList::formats()
|
QString MapList::formats()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
tr("Supported files") + " (*.map *.tar *.tba *.tif *.tiff *.xml);;"
|
tr("Supported files") + " (*.jnx *.map *.tar *.tba *.tif *.tiff *.xml);;"
|
||||||
|
+ tr("Garmin JNX maps") + " (*.jnx);;"
|
||||||
+ tr("OziExplorer maps") + " (*.map);;"
|
+ tr("OziExplorer maps") + " (*.map);;"
|
||||||
+ tr("TrekBuddy maps/atlases") + " (*.tar *.tba);;"
|
+ tr("TrekBuddy maps/atlases") + " (*.tar *.tba);;"
|
||||||
+ tr("GeoTIFF images") + " (*.tif *.tiff);;"
|
+ tr("GeoTIFF images") + " (*.tif *.tiff);;"
|
||||||
@ -137,6 +119,7 @@ QString MapList::formats()
|
|||||||
QStringList MapList::filter()
|
QStringList MapList::filter()
|
||||||
{
|
{
|
||||||
QStringList filter;
|
QStringList filter;
|
||||||
filter << "*.map" << "*.tba" << "*.tar" << "*.xml" << "*.tif" << "*.tiff";
|
filter << "*.jnx" << "*.map" << "*.tba" << "*.tar" << "*.xml" << "*.tif"
|
||||||
|
<< "*.tiff";
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool loadFile(const QString &path, bool *atlas, bool dir);
|
bool loadFile(const QString &path, bool *atlas, bool dir);
|
||||||
bool loadDirR(const QString &path);
|
bool loadDirR(const QString &path);
|
||||||
|
|
||||||
Map *loadListEntry(const QByteArray &line);
|
|
||||||
|
|
||||||
bool loadSource(const QString &path, bool dir);
|
bool loadSource(const QString &path, bool dir);
|
||||||
bool loadMap(const QString &path, bool dir);
|
bool loadMap(Map *map, const QString &path, bool dir);
|
||||||
bool loadAtlas(const QString &path, bool dir);
|
|
||||||
|
|
||||||
QList<Map*> _maps;
|
QList<Map*> _maps;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
@ -164,20 +164,18 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map *MapSource::loadFile(const QString &path)
|
Map *MapSource::loadMap(const QString &path, QString &errorString)
|
||||||
{
|
{
|
||||||
QFile file(path);
|
|
||||||
QXmlStreamReader reader;
|
|
||||||
Config config;
|
Config config;
|
||||||
Map *m;
|
QFile file(path);
|
||||||
|
|
||||||
|
|
||||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
_errorString = file.errorString();
|
errorString = file.errorString();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.setDevice(&file);
|
QXmlStreamReader reader(&file);
|
||||||
if (reader.readNextStartElement()) {
|
if (reader.readNextStartElement()) {
|
||||||
if (reader.name() == "map")
|
if (reader.name() == "map")
|
||||||
map(reader, config);
|
map(reader, config);
|
||||||
@ -185,59 +183,51 @@ Map *MapSource::loadFile(const QString &path)
|
|||||||
reader.raiseError("Not an online map source file");
|
reader.raiseError("Not an online map source file");
|
||||||
}
|
}
|
||||||
if (reader.error()) {
|
if (reader.error()) {
|
||||||
_errorString = QString("%1: %2").arg(reader.lineNumber())
|
errorString = QString("%1: %2").arg(reader.lineNumber())
|
||||||
.arg(reader.errorString());
|
.arg(reader.errorString());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.name.isEmpty()) {
|
if (config.name.isEmpty()) {
|
||||||
_errorString = "Missing name definition";
|
errorString = "Missing name definition";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (config.url.isEmpty()) {
|
if (config.url.isEmpty()) {
|
||||||
_errorString = "Missing URL definition";
|
errorString = "Missing URL definition";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (config.type == WMTS || config.type == WMS) {
|
if (config.type == WMTS || config.type == WMS) {
|
||||||
if (config.layer.isEmpty()) {
|
if (config.layer.isEmpty()) {
|
||||||
_errorString = "Missing layer definition";
|
errorString = "Missing layer definition";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (config.format.isEmpty()) {
|
if (config.format.isEmpty()) {
|
||||||
_errorString = "Missing format definition";
|
errorString = "Missing format definition";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.type == WMTS) {
|
if (config.type == WMTS) {
|
||||||
if (config.set.isEmpty()) {
|
if (config.set.isEmpty()) {
|
||||||
_errorString = "Missing set definiton";
|
errorString = "Missing set definiton";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.type == WMS) {
|
if (config.type == WMS) {
|
||||||
if (config.crs.isEmpty()) {
|
if (config.crs.isEmpty()) {
|
||||||
_errorString = "Missing CRS definiton";
|
errorString = "Missing CRS definiton";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.type == WMTS)
|
if (config.type == WMTS)
|
||||||
m = new WMTSMap(config.name, WMTS::Setup(config.url, config.layer,
|
return new WMTSMap(config.name, WMTS::Setup(config.url, config.layer,
|
||||||
config.set, config.style, config.format, config.rest,
|
config.set, config.style, config.format, config.rest,
|
||||||
config.coordinateSystem, config.dimensions, config.authorization));
|
config.coordinateSystem, config.dimensions, config.authorization));
|
||||||
else if (config.type == WMS)
|
else if (config.type == WMS)
|
||||||
m = new WMSMap(config.name, WMS::Setup(config.url, config.layer,
|
return new WMSMap(config.name, WMS::Setup(config.url, config.layer,
|
||||||
config.style, config.format, config.crs, config.coordinateSystem,
|
config.style, config.format, config.crs, config.coordinateSystem,
|
||||||
config.dimensions, config.authorization));
|
config.dimensions, config.authorization));
|
||||||
else
|
else
|
||||||
m = new OnlineMap(config.name, config.url, config.zooms, config.bounds,
|
return new OnlineMap(config.name, config.url, config.zooms,
|
||||||
config.authorization);
|
config.bounds, config.authorization);
|
||||||
|
|
||||||
if (!m->isValid()) {
|
|
||||||
_errorString = m->errorString();
|
|
||||||
delete m;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m;
|
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,7 @@ class QXmlStreamReader;
|
|||||||
class MapSource
|
class MapSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Map *loadFile(const QString &path);
|
static Map *loadMap(const QString &path, QString &errorString);
|
||||||
const QString &errorString() const {return _errorString;}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Type {
|
enum Type {
|
||||||
@ -42,11 +41,9 @@ private:
|
|||||||
Config();
|
Config();
|
||||||
};
|
};
|
||||||
|
|
||||||
RectC bounds(QXmlStreamReader &reader);
|
static RectC bounds(QXmlStreamReader &reader);
|
||||||
Range zooms(QXmlStreamReader &reader);
|
static Range zooms(QXmlStreamReader &reader);
|
||||||
void map(QXmlStreamReader &reader, Config &config);
|
static void map(QXmlStreamReader &reader, Config &config);
|
||||||
|
|
||||||
QString _errorString;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAPSOURCE_H
|
#endif // MAPSOURCE_H
|
||||||
|
@ -1,16 +1,123 @@
|
|||||||
#include <cmath>
|
/*
|
||||||
#include "common/coordinates.h"
|
* Based on libgeotrans with the following Source Code Disclaimer:
|
||||||
#include "common/wgs84.h"
|
|
||||||
|
1. The GEOTRANS source code ("the software") is provided free of charge by
|
||||||
|
the National Imagery and Mapping Agency (NIMA) of the United States
|
||||||
|
Department of Defense. Although NIMA makes no copyright claim under Title 17
|
||||||
|
U.S.C., NIMA claims copyrights in the source code under other legal regimes.
|
||||||
|
NIMA hereby grants to each user of the software a license to use and
|
||||||
|
distribute the software, and develop derivative works.
|
||||||
|
|
||||||
|
2. Warranty Disclaimer: The software was developed to meet only the internal
|
||||||
|
requirements of the U.S. National Imagery and Mapping Agency. The software
|
||||||
|
is provided "as is," and no warranty, express or implied, including but not
|
||||||
|
limited to the implied warranties of merchantability and fitness for
|
||||||
|
particular purpose or arising by statute or otherwise in law or from a
|
||||||
|
course of dealing or usage in trade, is made by NIMA as to the accuracy and
|
||||||
|
functioning of the software.
|
||||||
|
|
||||||
|
3. NIMA and its personnel are not required to provide technical support or
|
||||||
|
general assistance with respect to the software.
|
||||||
|
|
||||||
|
4. Neither NIMA nor its personnel will be liable for any claims, losses, or
|
||||||
|
damages arising from or connected with the use of the software. The user
|
||||||
|
agrees to hold harmless the United States National Imagery and Mapping
|
||||||
|
Agency. The user's sole and exclusive remedy is to stop using the software.
|
||||||
|
|
||||||
|
5. NIMA requests that products developed using the software credit the
|
||||||
|
source of the software with the following statement, "The product was
|
||||||
|
developed using GEOTRANS, a product of the National Imagery and Mapping
|
||||||
|
Agency and U.S. Army Engineering Research and Development Center."
|
||||||
|
|
||||||
|
6. For any products developed using the software, NIMA requires a disclaimer
|
||||||
|
that use of the software does not indicate endorsement or approval of the
|
||||||
|
product by the Secretary of Defense or the National Imagery and Mapping
|
||||||
|
Agency. Pursuant to the United States Code, 10 U.S.C. Sec. 2797, the name of
|
||||||
|
the National Imagery and Mapping Agency, the initials "NIMA", the seal of
|
||||||
|
the National Imagery and Mapping Agency, or any colorable imitation thereof
|
||||||
|
shall not be used to imply approval, endorsement, or authorization of a
|
||||||
|
product without prior written permission from United States Secretary of
|
||||||
|
Defense.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ellipsoid.h"
|
||||||
#include "mercator.h"
|
#include "mercator.h"
|
||||||
|
|
||||||
|
Mercator::Mercator(const Ellipsoid *ellipsoid, double latitudeOrigin,
|
||||||
|
double longitudeOrigin, double falseEasting, double falseNorthing)
|
||||||
|
{
|
||||||
|
double es = ellipsoid->es();
|
||||||
|
double es2;
|
||||||
|
double es3;
|
||||||
|
double es4;
|
||||||
|
double sin_olat;
|
||||||
|
|
||||||
|
_latitudeOrigin = deg2rad(latitudeOrigin);
|
||||||
|
_longitudeOrigin = deg2rad(longitudeOrigin);
|
||||||
|
if (_longitudeOrigin > M_PI)
|
||||||
|
_longitudeOrigin -= M_2_PI;
|
||||||
|
_falseNorthing = falseNorthing;
|
||||||
|
_falseEasting = falseEasting;
|
||||||
|
|
||||||
|
_a = ellipsoid->radius();
|
||||||
|
_e = sqrt(es);
|
||||||
|
|
||||||
|
sin_olat = sin(_latitudeOrigin);
|
||||||
|
_scaleFactor = 1.0 / (sqrt(1.e0 - es * sin_olat * sin_olat)
|
||||||
|
/ cos(_latitudeOrigin));
|
||||||
|
es2 = es * es;
|
||||||
|
es3 = es2 * es;
|
||||||
|
es4 = es3 * es;
|
||||||
|
_ab = es / 2.e0 + 5.e0 * es2 / 24.e0 + es3 / 12.e0 + 13.e0 * es4 / 360.e0;
|
||||||
|
_bb = 7.e0 * es2 / 48.e0 + 29.e0 * es3 / 240.e0 + 811.e0 * es4 / 11520.e0;
|
||||||
|
_cb = 7.e0 * es3 / 120.e0 + 81.e0 * es4 / 1120.e0;
|
||||||
|
_db = 4279.e0 * es4 / 161280.e0;
|
||||||
|
}
|
||||||
|
|
||||||
PointD Mercator::ll2xy(const Coordinates &c) const
|
PointD Mercator::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
return PointD(deg2rad(c.lon()) * WGS84_RADIUS,
|
double lon = deg2rad(c.lon());
|
||||||
log(tan(M_PI/4.0 + deg2rad(c.lat())/2.0)) * WGS84_RADIUS);
|
double lat = deg2rad(c.lat());
|
||||||
|
double ctanz2;
|
||||||
|
double e_x_sinlat;
|
||||||
|
double delta_lon;
|
||||||
|
double tan_temp;
|
||||||
|
double pow_temp;
|
||||||
|
|
||||||
|
if (lon > M_PI)
|
||||||
|
lon -= M_2_PI;
|
||||||
|
e_x_sinlat = _e * sin(lat);
|
||||||
|
tan_temp = tan(M_PI_4 + lat / 2.e0);
|
||||||
|
pow_temp = pow((1.e0 - e_x_sinlat) / (1.e0 + e_x_sinlat), _e / 2.e0);
|
||||||
|
ctanz2 = tan_temp * pow_temp;
|
||||||
|
delta_lon = lon - _longitudeOrigin;
|
||||||
|
if (delta_lon > M_PI)
|
||||||
|
delta_lon -= M_2_PI;
|
||||||
|
if (delta_lon < -M_PI)
|
||||||
|
delta_lon += M_2_PI;
|
||||||
|
|
||||||
|
return PointD(_scaleFactor * _a * delta_lon + _falseEasting,
|
||||||
|
_scaleFactor * _a * log(ctanz2) + _falseNorthing);
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates Mercator::xy2ll(const PointD &p) const
|
Coordinates Mercator::xy2ll(const PointD &p) const
|
||||||
{
|
{
|
||||||
return Coordinates(rad2deg(p.x() / WGS84_RADIUS),
|
double dx;
|
||||||
rad2deg(2 * atan(exp(p.y() / WGS84_RADIUS)) - M_PI/2));
|
double dy;
|
||||||
|
double xphi;
|
||||||
|
double lat, lon;
|
||||||
|
|
||||||
|
dy = p.y() - _falseNorthing;
|
||||||
|
dx = p.x() - _falseEasting;
|
||||||
|
lon = _longitudeOrigin + dx / (_scaleFactor * _a);
|
||||||
|
xphi = M_PI_2 - 2.e0 * atan(1.e0 / exp(dy / (_scaleFactor * _a)));
|
||||||
|
lat = xphi + _ab * sin(2.e0 * xphi) + _bb * sin(4.e0 * xphi)
|
||||||
|
+ _cb * sin(6.e0 * xphi) + _db * sin(8.e0 * xphi);
|
||||||
|
if (lon > M_PI)
|
||||||
|
lon -= M_2_PI;
|
||||||
|
if (lon < -M_PI)
|
||||||
|
lon += M_2_PI;
|
||||||
|
|
||||||
|
return Coordinates(rad2deg(lon), rad2deg(lat));
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,27 @@
|
|||||||
|
|
||||||
#include "ct.h"
|
#include "ct.h"
|
||||||
|
|
||||||
|
class Ellipsoid;
|
||||||
|
|
||||||
class Mercator : public CT
|
class Mercator : public CT
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Mercator(const Ellipsoid *ellipsoid, double latitudeOrigin,
|
||||||
|
double longitudeOrigin, double falseEasting, double falseNorthing);
|
||||||
|
|
||||||
virtual CT *clone() const {return new Mercator(*this);}
|
virtual CT *clone() const {return new Mercator(*this);}
|
||||||
|
|
||||||
virtual PointD ll2xy(const Coordinates &c) const;
|
virtual PointD ll2xy(const Coordinates &c) const;
|
||||||
virtual Coordinates xy2ll(const PointD &p) const;
|
virtual Coordinates xy2ll(const PointD &p) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
double _a, _e;
|
||||||
|
double _latitudeOrigin;
|
||||||
|
double _longitudeOrigin;
|
||||||
|
double _falseNorthing;
|
||||||
|
double _falseEasting;
|
||||||
|
double _scaleFactor;
|
||||||
|
double _ab, _bb, _cb, _db;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MERCATOR_H
|
#endif // MERCATOR_H
|
||||||
|
@ -262,12 +262,10 @@ void OfflineMap::drawTiled(QPainter *painter, const QRectF &rect) const
|
|||||||
} else
|
} else
|
||||||
pixmap = QPixmap(tileName);
|
pixmap = QPixmap(tileName);
|
||||||
|
|
||||||
if (pixmap.isNull()) {
|
if (pixmap.isNull())
|
||||||
qWarning("%s: error loading tile image", qPrintable(
|
qWarning("%s: error loading tile image", qPrintable(
|
||||||
_tile.path.arg(QString::number(x), QString::number(y))));
|
_tile.path.arg(QString::number(x), QString::number(y))));
|
||||||
painter->fillRect(QRectF(QPoint(x, y), _tile.size),
|
else
|
||||||
_backgroundColor);
|
|
||||||
} else
|
|
||||||
painter->drawPixmap(QPoint(x, y), pixmap);
|
painter->drawPixmap(QPoint(x, y), pixmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,11 +292,9 @@ void OfflineMap::drawOZF(QPainter *painter, const QRectF &rect) const
|
|||||||
QPixmapCache::insert(key, pixmap);
|
QPixmapCache::insert(key, pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixmap.isNull()) {
|
if (pixmap.isNull())
|
||||||
qWarning("%s: error loading tile image", qPrintable(key));
|
qWarning("%s: error loading tile image", qPrintable(key));
|
||||||
painter->fillRect(QRectF(QPoint(x, y), _ozf->tileSize()),
|
else
|
||||||
_backgroundColor);
|
|
||||||
} else
|
|
||||||
painter->drawPixmap(QPoint(x, y), pixmap);
|
painter->drawPixmap(QPoint(x, y), pixmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,17 +317,15 @@ void OfflineMap::draw(QPainter *painter, const QRectF &rect, bool block)
|
|||||||
drawTiled(painter, rect);
|
drawTiled(painter, rect);
|
||||||
else if (_img && !_img->isNull())
|
else if (_img && !_img->isNull())
|
||||||
drawImage(painter, rect);
|
drawImage(painter, rect);
|
||||||
else
|
|
||||||
painter->fillRect(rect, _backgroundColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF OfflineMap::ll2xy(const Coordinates &c) const
|
QPointF OfflineMap::ll2xy(const Coordinates &c)
|
||||||
{
|
{
|
||||||
QPointF p(_transform.proj2img(_projection.ll2xy(c)));
|
QPointF p(_transform.proj2img(_projection.ll2xy(c)));
|
||||||
return _ozf ? QPointF(p.x() * _scale.x(), p.y() * _scale.y()) : p;
|
return _ozf ? QPointF(p.x() * _scale.x(), p.y() * _scale.y()) : p;
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates OfflineMap::xy2ll(const QPointF &p) const
|
Coordinates OfflineMap::xy2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
return _ozf
|
return _ozf
|
||||||
? _projection.xy2ll(_transform.img2proj(QPointF(p.x() / _scale.x(),
|
? _projection.xy2ll(_transform.img2proj(QPointF(p.x() / _scale.x(),
|
||||||
@ -346,17 +340,6 @@ QRectF OfflineMap::bounds() const
|
|||||||
: QRectF(QPointF(0, 0), _map.size);
|
: QRectF(QPointF(0, 0), _map.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal OfflineMap::resolution(const QRectF &rect) const
|
|
||||||
{
|
|
||||||
Coordinates tl = xy2ll((rect.topLeft()));
|
|
||||||
Coordinates br = xy2ll(rect.bottomRight());
|
|
||||||
|
|
||||||
qreal ds = tl.distanceTo(br);
|
|
||||||
qreal ps = QLineF(rect.topLeft(), rect.bottomRight()).length();
|
|
||||||
|
|
||||||
return ds/ps;
|
|
||||||
}
|
|
||||||
|
|
||||||
int OfflineMap::zoomFit(const QSize &size, const RectC &rect)
|
int OfflineMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
{
|
{
|
||||||
if (!_ozf)
|
if (!_ozf)
|
||||||
|
@ -21,7 +21,6 @@ public:
|
|||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds() const;
|
||||||
qreal resolution(const QRectF &rect) const;
|
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
void setZoom(int zoom) {_zoom = zoom;}
|
void setZoom(int zoom) {_zoom = zoom;}
|
||||||
@ -29,10 +28,8 @@ public:
|
|||||||
int zoomIn();
|
int zoomIn();
|
||||||
int zoomOut();
|
int zoomOut();
|
||||||
|
|
||||||
QPointF ll2xy(const Coordinates &c)
|
QPointF ll2xy(const Coordinates &c);
|
||||||
{return static_cast<const OfflineMap &>(*this).ll2xy(c);}
|
Coordinates xy2ll(const QPointF &p);
|
||||||
Coordinates xy2ll(const QPointF &p)
|
|
||||||
{return static_cast<const OfflineMap &>(*this).xy2ll(p);}
|
|
||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, bool block);
|
void draw(QPainter *painter, const QRectF &rect, bool block);
|
||||||
|
|
||||||
@ -57,9 +54,6 @@ private:
|
|||||||
bool isValid() const {return size.isValid() && !path.isEmpty();}
|
bool isValid() const {return size.isValid() && !path.isEmpty();}
|
||||||
};
|
};
|
||||||
|
|
||||||
QPointF ll2xy(const Coordinates &c) const;
|
|
||||||
Coordinates xy2ll(const QPointF &p) const;
|
|
||||||
|
|
||||||
bool setTileInfo(const QStringList &tiles, const QString &path = QString());
|
bool setTileInfo(const QStringList &tiles, const QString &path = QString());
|
||||||
bool setImageInfo(const QString &path);
|
bool setImageInfo(const QString &path);
|
||||||
|
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
static QPointF ll2m(const Coordinates &c)
|
static QPointF ll2m(const Coordinates &c)
|
||||||
{
|
{
|
||||||
return QPointF(c.lon(), rad2deg(log(tan(M_PI/4.0 + deg2rad(c.lat())/2.0))));
|
return QPointF(c.lon(), rad2deg(log(tan(M_PI_4 + deg2rad(c.lat())/2.0))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Coordinates m2ll(const QPointF &p)
|
static Coordinates m2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
return Coordinates(p.x(), rad2deg(2 * atan(exp(deg2rad(p.y()))) - M_PI/2));
|
return Coordinates(p.x(), rad2deg(2.0 * atan(exp(deg2rad(p.y()))) - M_PI_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static QPoint mercator2tile(const QPointF &m, int z)
|
static QPoint mercator2tile(const QPointF &m, int z)
|
||||||
@ -92,7 +92,7 @@ int OnlineMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal OnlineMap::resolution(const QRectF &rect) const
|
qreal OnlineMap::resolution(const QRectF &rect)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = zoom2scale(_zoom);
|
||||||
|
|
||||||
@ -136,10 +136,7 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, bool block)
|
|||||||
Tile &t = tiles[i];
|
Tile &t = tiles[i];
|
||||||
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * TILE_SIZE,
|
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * TILE_SIZE,
|
||||||
tl.y() + (t.xy().y() - tile.y()) * TILE_SIZE);
|
tl.y() + (t.xy().y() - tile.y()) * TILE_SIZE);
|
||||||
if (t.pixmap().isNull())
|
if (!t.pixmap().isNull())
|
||||||
painter->fillRect(QRect(tp, QSize(TILE_SIZE, TILE_SIZE)),
|
|
||||||
_backgroundColor);
|
|
||||||
else
|
|
||||||
painter->drawPixmap(tp, t.pixmap());
|
painter->drawPixmap(tp, t.pixmap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public:
|
|||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds() const;
|
||||||
qreal resolution(const QRectF &rect) const;
|
qreal resolution(const QRectF &rect);
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
void setZoom(int zoom) {_zoom = zoom;}
|
void setZoom(int zoom) {_zoom = zoom;}
|
||||||
|
@ -16,7 +16,15 @@ private:
|
|||||||
PCS _pcs;
|
PCS _pcs;
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<PCS::Entry> PCS::_pcss;
|
QList<PCS::Entry> PCS::_pcss = defaults();
|
||||||
|
|
||||||
|
QList<PCS::Entry> PCS::defaults()
|
||||||
|
{
|
||||||
|
QList<PCS::Entry> list;
|
||||||
|
list.append(PCS::Entry(3857, 3856, PCS(&GCS::WGS84(), 1024,
|
||||||
|
Projection::Setup(0, 0, NAN, 0, 0, NAN, NAN), 9001, 4499)));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
static bool parameter(int key, double val, int units, Projection::Setup &setup)
|
static bool parameter(int key, double val, int units, Projection::Setup &setup)
|
||||||
{
|
{
|
||||||
@ -32,6 +40,7 @@ static bool parameter(int key, double val, int units, Projection::Setup &setup)
|
|||||||
case 8802:
|
case 8802:
|
||||||
case 8812:
|
case 8812:
|
||||||
case 8822:
|
case 8822:
|
||||||
|
case 8833:
|
||||||
{AngularUnits au(units);
|
{AngularUnits au(units);
|
||||||
if (au.isNull())
|
if (au.isNull())
|
||||||
return false;
|
return false;
|
||||||
@ -39,6 +48,7 @@ static bool parameter(int key, double val, int units, Projection::Setup &setup)
|
|||||||
return true;
|
return true;
|
||||||
case 8805:
|
case 8805:
|
||||||
case 8815:
|
case 8815:
|
||||||
|
case 8819:
|
||||||
setup.setScale(val);
|
setup.setScale(val);
|
||||||
return true;
|
return true;
|
||||||
case 8806:
|
case 8806:
|
||||||
@ -58,12 +68,14 @@ static bool parameter(int key, double val, int units, Projection::Setup &setup)
|
|||||||
setup.setFalseNorthing(lu.toMeters(val));}
|
setup.setFalseNorthing(lu.toMeters(val));}
|
||||||
return true;
|
return true;
|
||||||
case 8813:
|
case 8813:
|
||||||
|
case 8818:
|
||||||
case 8823:
|
case 8823:
|
||||||
{AngularUnits au(units);
|
{AngularUnits au(units);
|
||||||
if (au.isNull())
|
if (au.isNull())
|
||||||
return false;
|
return false;
|
||||||
setup.setStandardParallel1(au.toDegrees(val));}
|
setup.setStandardParallel1(au.toDegrees(val));}
|
||||||
return true;
|
return true;
|
||||||
|
case 1036:
|
||||||
case 8814:
|
case 8814:
|
||||||
case 8824:
|
case 8824:
|
||||||
{AngularUnits au(units);
|
{AngularUnits au(units);
|
||||||
|
@ -25,10 +25,11 @@ public:
|
|||||||
const CoordinateSystem &coordinateSystem() const {return _cs;}
|
const CoordinateSystem &coordinateSystem() const {return _cs;}
|
||||||
|
|
||||||
bool isNull() const
|
bool isNull() const
|
||||||
{return (_gcs->isNull() && _units.isNull() && _method.isNull()
|
{return (!_gcs && _units.isNull() && _method.isNull() && _setup.isNull()
|
||||||
&& _setup.isNull());}
|
&& _cs.isNull());}
|
||||||
bool isValid() const
|
bool isValid() const
|
||||||
{return (_gcs->isValid() && _units.isValid() && _method.isValid());}
|
{return (_gcs && _gcs->isValid() && _units.isValid()
|
||||||
|
&& _method.isValid() && _cs.isValid());}
|
||||||
|
|
||||||
static void loadList(const QString &path);
|
static void loadList(const QString &path);
|
||||||
static const PCS *pcs(int id);
|
static const PCS *pcs(int id);
|
||||||
@ -37,6 +38,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
class Entry;
|
class Entry;
|
||||||
|
|
||||||
|
static QList<PCS::Entry> defaults();
|
||||||
|
|
||||||
const GCS *_gcs;
|
const GCS *_gcs;
|
||||||
Projection::Method _method;
|
Projection::Method _method;
|
||||||
Projection::Setup _setup;
|
Projection::Setup _setup;
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#include "datum.h"
|
#include "datum.h"
|
||||||
#include "mercator.h"
|
#include "mercator.h"
|
||||||
|
#include "webmercator.h"
|
||||||
#include "transversemercator.h"
|
#include "transversemercator.h"
|
||||||
#include "lambertconic.h"
|
#include "lambertconic.h"
|
||||||
#include "albersequal.h"
|
#include "albersequal.h"
|
||||||
#include "lambertazimuthal.h"
|
#include "lambertazimuthal.h"
|
||||||
|
#include "krovak.h"
|
||||||
#include "latlon.h"
|
#include "latlon.h"
|
||||||
#include "gcs.h"
|
#include "gcs.h"
|
||||||
#include "pcs.h"
|
#include "pcs.h"
|
||||||
@ -14,13 +16,15 @@ Projection::Method::Method(int id)
|
|||||||
{
|
{
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 1024:
|
case 1024:
|
||||||
|
case 1041:
|
||||||
case 9801:
|
case 9801:
|
||||||
case 9802:
|
case 9802:
|
||||||
|
case 9804:
|
||||||
case 9807:
|
case 9807:
|
||||||
case 9815:
|
case 9815:
|
||||||
|
case 9819:
|
||||||
case 9820:
|
case 9820:
|
||||||
case 9822:
|
case 9822:
|
||||||
case 9841:
|
|
||||||
_id = id;
|
_id = id;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -36,8 +40,13 @@ Projection::Projection(const PCS *pcs) : _gcs(pcs->gcs()), _units(pcs->units()),
|
|||||||
|
|
||||||
switch (pcs->method().id()) {
|
switch (pcs->method().id()) {
|
||||||
case 1024:
|
case 1024:
|
||||||
case 9841:
|
_ct = new WebMercator();
|
||||||
_ct = new Mercator();
|
break;
|
||||||
|
case 1041:
|
||||||
|
_ct = new KrovakNE(ellipsoid, setup.standardParallel1(),
|
||||||
|
setup.standardParallel2(), setup.scale(), setup.latitudeOrigin(),
|
||||||
|
setup.longitudeOrigin(), setup.falseEasting(),
|
||||||
|
setup.falseNorthing());
|
||||||
break;
|
break;
|
||||||
case 9801:
|
case 9801:
|
||||||
case 9815: // Oblique mercator aproximation using LCC1
|
case 9815: // Oblique mercator aproximation using LCC1
|
||||||
@ -51,11 +60,22 @@ Projection::Projection(const PCS *pcs) : _gcs(pcs->gcs()), _units(pcs->units()),
|
|||||||
setup.longitudeOrigin(), setup.falseEasting(),
|
setup.longitudeOrigin(), setup.falseEasting(),
|
||||||
setup.falseNorthing());
|
setup.falseNorthing());
|
||||||
break;
|
break;
|
||||||
|
case 9804:
|
||||||
|
_ct = new Mercator(ellipsoid, setup.latitudeOrigin(),
|
||||||
|
setup.longitudeOrigin(), setup.falseEasting(),
|
||||||
|
setup.falseNorthing());
|
||||||
|
break;
|
||||||
case 9807:
|
case 9807:
|
||||||
_ct = new TransverseMercator(ellipsoid, setup.latitudeOrigin(),
|
_ct = new TransverseMercator(ellipsoid, setup.latitudeOrigin(),
|
||||||
setup.longitudeOrigin(), setup.scale(), setup.falseEasting(),
|
setup.longitudeOrigin(), setup.scale(), setup.falseEasting(),
|
||||||
setup.falseNorthing());
|
setup.falseNorthing());
|
||||||
break;
|
break;
|
||||||
|
case 9819:
|
||||||
|
_ct = new Krovak(ellipsoid, setup.standardParallel1(),
|
||||||
|
setup.standardParallel2(), setup.scale(), setup.latitudeOrigin(),
|
||||||
|
setup.longitudeOrigin(), setup.falseEasting(),
|
||||||
|
setup.falseNorthing());
|
||||||
|
break;
|
||||||
case 9820:
|
case 9820:
|
||||||
_ct = new LambertAzimuthal(ellipsoid, setup.latitudeOrigin(),
|
_ct = new LambertAzimuthal(ellipsoid, setup.latitudeOrigin(),
|
||||||
setup.longitudeOrigin(), setup.falseEasting(),
|
setup.longitudeOrigin(), setup.falseEasting(),
|
||||||
@ -105,14 +125,14 @@ Projection &Projection::operator=(const Projection &p)
|
|||||||
|
|
||||||
PointD Projection::ll2xy(const Coordinates &c) const
|
PointD Projection::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
return isValid()
|
Q_ASSERT(isValid());
|
||||||
? _units.fromMeters(_ct->ll2xy(_gcs->fromWGS84(c))) : PointD();
|
return _units.fromMeters(_ct->ll2xy(_gcs->fromWGS84(c)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates Projection::xy2ll(const PointD &p) const
|
Coordinates Projection::xy2ll(const PointD &p) const
|
||||||
{
|
{
|
||||||
return isValid()
|
Q_ASSERT(isValid());
|
||||||
? _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p))) : Coordinates();
|
return _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef TILE_H
|
#ifndef TILE_H
|
||||||
#define TILE_H
|
#define TILE_H
|
||||||
|
|
||||||
|
#include <QVariant>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -72,11 +72,9 @@ TransverseMercator::TransverseMercator(const Ellipsoid *ellipsoid,
|
|||||||
_falseEasting = falseEasting;
|
_falseEasting = falseEasting;
|
||||||
_falseNorthing = falseNorthing;
|
_falseNorthing = falseNorthing;
|
||||||
|
|
||||||
_es = 2 * ellipsoid->flattening() - ellipsoid->flattening()
|
_es = ellipsoid->es();
|
||||||
* ellipsoid->flattening();
|
|
||||||
_ebs = (1 / (1 - _es)) - 1;
|
_ebs = (1 / (1 - _es)) - 1;
|
||||||
|
b = ellipsoid->b();
|
||||||
b = _a * (1 - ellipsoid->flattening());
|
|
||||||
|
|
||||||
tn = (_a - b) / (_a + b);
|
tn = (_a - b) / (_a + b);
|
||||||
tn2 = tn * tn;
|
tn2 = tn * tn;
|
||||||
@ -109,9 +107,9 @@ PointD TransverseMercator::ll2xy(const Coordinates &c) const
|
|||||||
dlam = deg2rad(c.lon()) - _longitudeOrigin;
|
dlam = deg2rad(c.lon()) - _longitudeOrigin;
|
||||||
|
|
||||||
if (dlam > M_PI)
|
if (dlam > M_PI)
|
||||||
dlam -= (2 * M_PI);
|
dlam -= M_2_PI;
|
||||||
if (dlam < -M_PI)
|
if (dlam < -M_PI)
|
||||||
dlam += (2 * M_PI);
|
dlam += M_2_PI;
|
||||||
if (fabs(dlam) < 2.e-10)
|
if (fabs(dlam) < 2.e-10)
|
||||||
dlam = 0.0;
|
dlam = 0.0;
|
||||||
|
|
||||||
@ -237,20 +235,20 @@ Coordinates TransverseMercator::xy2ll(const PointD &p) const
|
|||||||
lat = M_PI - lat;
|
lat = M_PI - lat;
|
||||||
lon += M_PI;
|
lon += M_PI;
|
||||||
if (lon > M_PI)
|
if (lon > M_PI)
|
||||||
lon -= (2 * M_PI);
|
lon -= M_2_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (lat < deg2rad(-90.0)) {
|
while (lat < deg2rad(-90.0)) {
|
||||||
lat = - (lat + M_PI);
|
lat = - (lat + M_PI);
|
||||||
lon += M_PI;
|
lon += M_PI;
|
||||||
if (lon > M_PI)
|
if (lon > M_PI)
|
||||||
lon -= (2 * M_PI);
|
lon -= M_2_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lon > (2 * M_PI))
|
if (lon > M_2_PI)
|
||||||
lon -= (2 * M_PI);
|
lon -= M_2_PI;
|
||||||
if (lon < -M_PI)
|
if (lon < -M_PI)
|
||||||
lon += (2 * M_PI);
|
lon += M_2_PI;
|
||||||
|
|
||||||
return Coordinates(rad2deg(lon), rad2deg(lat));
|
return Coordinates(rad2deg(lon), rad2deg(lat));
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ private:
|
|||||||
double _falseEasting;
|
double _falseEasting;
|
||||||
double _falseNorthing;
|
double _falseNorthing;
|
||||||
double _a;
|
double _a;
|
||||||
|
|
||||||
double _es;
|
double _es;
|
||||||
double _ebs;
|
double _ebs;
|
||||||
double _ap, _bp, _cp, _dp, _ep;
|
double _ap, _bp, _cp, _dp, _ep;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user