mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-03 22:39:15 +02:00
Compare commits
95 Commits
Author | SHA1 | Date | |
---|---|---|---|
18fc6cc3e2 | |||
9815f0bff2 | |||
805cbe921c | |||
d529055ea3 | |||
5d590b7c86 | |||
1003c7b56f | |||
820f967bd6 | |||
27632bf07e | |||
ee5b8fa333 | |||
7e42b57d73 | |||
292fc9b433 | |||
089d796194 | |||
2677bb77f8 | |||
13dba26d3e | |||
9675e19b94 | |||
8d3fcc7a17 | |||
8dc5cb7aa8 | |||
af99e4e05a | |||
d18c0d1643 | |||
b9a93d30c0 | |||
2b6d3799ec | |||
152828042f | |||
e1683a7560 | |||
444cf344a9 | |||
7ac0bcf6d2 | |||
a1ac306bfc | |||
db4a436ff5 | |||
84a6f6c875 | |||
06f2c883d4 | |||
fc95ebfe2b | |||
4b64ee467c | |||
331cb48e11 | |||
fce0c49504 | |||
f670fb0859 | |||
1e45713aa4 | |||
7265c85b83 | |||
4d156044d0 | |||
17c9416532 | |||
8e9db2354e | |||
544a838821 | |||
44d84bf19e | |||
4ca9c79dc4 | |||
cb77cc37c4 | |||
98dd8c264c | |||
84d860e2a2 | |||
e10f8e9c1b | |||
f433f855a4 | |||
c90a03e22c | |||
fbc0fd86cf | |||
aa07b20aa4 | |||
8a7edcfd8d | |||
04a145a2e7 | |||
66f0f6a202 | |||
5698b4c9b0 | |||
77c4eda385 | |||
d6de3acbd2 | |||
652ed8e919 | |||
58e1980b0d | |||
fda33cc95b | |||
02e724fefb | |||
da220c4b62 | |||
6ffc71fd36 | |||
635e2f1fe3 | |||
23e4e66c1b | |||
1739625896 | |||
e9ef68a81c | |||
06205470fe | |||
c535632eb6 | |||
9f1f06577c | |||
0e45831111 | |||
0c8e864d32 | |||
c9cac70e1f | |||
045cbe81bf | |||
bffd1d9172 | |||
b8102d6bb7 | |||
fc80bd1b7c | |||
2441c4996d | |||
89878fade1 | |||
83b7741ed9 | |||
f44b14473d | |||
699de8b133 | |||
b7dd11fa1f | |||
0a32a9b865 | |||
02ad65461c | |||
5fa52b0166 | |||
99fa39030f | |||
6ebf749bdc | |||
5e74642dc8 | |||
b1d1cae9dd | |||
84f41b5aa9 | |||
de2278ba04 | |||
e90f152432 | |||
8deab1c9ca | |||
51e0f9a9c6 | |||
e330abe180 |
@ -1,4 +1,4 @@
|
||||
version: 4.17.{build}
|
||||
version: 5.1.{build}
|
||||
configuration: Release
|
||||
platform: Any CPU
|
||||
environment:
|
||||
@ -34,11 +34,11 @@ build_script:
|
||||
|
||||
copy pkg\%NSI% installer
|
||||
|
||||
copy pkg\datums.csv installer
|
||||
xcopy pkg\csv installer\csv /i
|
||||
|
||||
copy pkg\ellipsoids.csv installer
|
||||
xcopy pkg\maps installer\maps /i
|
||||
|
||||
copy pkg\maps.txt installer
|
||||
xcopy lang\*.qm installer\translations\ /sy
|
||||
|
||||
copy licence.txt installer
|
||||
|
||||
|
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# C++ objects and libs
|
||||
*.o
|
||||
|
||||
# Qt-es
|
||||
/.qmake.stash
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
qrc_*.cpp
|
||||
Makefile*
|
||||
*.qm
|
||||
|
||||
# Binary
|
||||
GPXSee
|
7
CONTRIBUTING.md
Normal file
7
CONTRIBUTING.md
Normal file
@ -0,0 +1,7 @@
|
||||
Only localization contributions are accepted at the moment, code pull requests will be rejected.
|
||||
|
||||
The rationale is, that I want leave the possibility to distribute GPXsee builds in the OS X/Windows
|
||||
stores under a non-GPL licence open. In the future, code pull requests under a QT-like contribution
|
||||
agreement [1] will be possible.
|
||||
|
||||
[1] https://d21tv0wm5mksdn.cloudfront.net/wp-content/uploads/2015/03/Qt-ContributionLicenseAgreement_v1_2_FINAL.pdf
|
@ -4,7 +4,7 @@ KML, FIT, IGC and NMEA files.
|
||||
|
||||
## Features
|
||||
* User-definable online maps.
|
||||
* Offline maps (OziExplorer maps and TrekBuddy maps/atlases).
|
||||
* Offline maps (OziExplorer maps, TrekBuddy maps/atlases, GeoTIFF images).
|
||||
* Elevation, speed, heart rate, cadence, power and temperature graphs.
|
||||
* Support for multiple tracks in one view.
|
||||
* Support for POI files.
|
||||
|
60
gpxsee.pro
60
gpxsee.pro
@ -1,5 +1,5 @@
|
||||
TARGET = GPXSee
|
||||
VERSION = 4.17
|
||||
VERSION = 5.1
|
||||
QT += core \
|
||||
gui \
|
||||
network
|
||||
@ -14,6 +14,7 @@ HEADERS += src/config.h \
|
||||
src/common/range.h \
|
||||
src/common/rectc.h \
|
||||
src/common/wgs84.h \
|
||||
src/common/str2int.h \
|
||||
src/GUI/app.h \
|
||||
src/GUI/icons.h \
|
||||
src/GUI/gui.h \
|
||||
@ -86,7 +87,11 @@ HEADERS += src/config.h \
|
||||
src/map/ozf.h \
|
||||
src/map/atlas.h \
|
||||
src/map/matrix.h \
|
||||
src/map/misc.h \
|
||||
src/map/geotiff.h \
|
||||
src/map/pcs.h \
|
||||
src/map/transform.h \
|
||||
src/map/mapfile.h \
|
||||
src/map/tifffile.h \
|
||||
src/data/graph.h \
|
||||
src/data/poi.h \
|
||||
src/data/waypoint.h \
|
||||
@ -106,11 +111,17 @@ HEADERS += src/config.h \
|
||||
src/data/fitparser.h \
|
||||
src/data/igcparser.h \
|
||||
src/data/nmeaparser.h \
|
||||
src/data/str2int.h
|
||||
src/map/gcs.h \
|
||||
src/map/angularunits.h \
|
||||
src/map/primemeridian.h \
|
||||
src/map/linearunits.h \
|
||||
src/map/ct.h \
|
||||
src/map/mapsource.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/common/coordinates.cpp \
|
||||
src/common/rectc.cpp \
|
||||
src/common/range.cpp \
|
||||
src/common/str2int.cpp \
|
||||
src/GUI/app.cpp \
|
||||
src/GUI/gui.cpp \
|
||||
src/GUI/axisitem.cpp \
|
||||
@ -163,13 +174,17 @@ SOURCES += src/main.cpp \
|
||||
src/map/matrix.cpp \
|
||||
src/map/ellipsoid.cpp \
|
||||
src/map/datum.cpp \
|
||||
src/map/projection.cpp \
|
||||
src/map/mercator.cpp \
|
||||
src/map/transversemercator.cpp \
|
||||
src/map/utm.cpp \
|
||||
src/map/lambertconic.cpp \
|
||||
src/map/albersequal.cpp \
|
||||
src/map/lambertazimuthal.cpp \
|
||||
src/map/geotiff.cpp \
|
||||
src/map/pcs.cpp \
|
||||
src/map/transform.cpp \
|
||||
src/map/mapfile.cpp \
|
||||
src/map/tifffile.cpp \
|
||||
src/data/data.cpp \
|
||||
src/data/poi.cpp \
|
||||
src/data/track.cpp \
|
||||
@ -182,25 +197,40 @@ SOURCES += src/main.cpp \
|
||||
src/data/fitparser.cpp \
|
||||
src/data/igcparser.cpp \
|
||||
src/data/nmeaparser.cpp \
|
||||
src/data/str2int.cpp
|
||||
src/map/projection.cpp \
|
||||
src/map/gcs.cpp \
|
||||
src/map/angularunits.cpp \
|
||||
src/map/primemeridian.cpp \
|
||||
src/map/linearunits.cpp \
|
||||
src/map/mapsource.cpp
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts \
|
||||
lang/gpxsee_sv.ts \
|
||||
lang/gpxsee_de.ts
|
||||
lang/gpxsee_de.ts \
|
||||
lang/gpxsee_ru.ts \
|
||||
lang/gpxsee_fi.ts \
|
||||
lang/gpxsee_fr.ts
|
||||
macx {
|
||||
ICON = icons/gpxsee.icns
|
||||
QMAKE_INFO_PLIST = Info.plist
|
||||
APP_RESOURCES.files = icons/gpx.icns \
|
||||
icons/tcx.icns \
|
||||
QMAKE_INFO_PLIST = pkg/Info.plist
|
||||
LOCALE.path = Contents/Resources/translations
|
||||
LOCALE.files = lang/gpxsee_cs.qm \
|
||||
lang/gpxsee_de.qm \
|
||||
lang/gpxsee_fi.qm \
|
||||
lang/gpxsee_fr.qm \
|
||||
lang/gpxsee_ru.qm \
|
||||
lang/gpxsee_sv.qm
|
||||
CSV.path = Contents/Resources
|
||||
CSV.files = pkg/csv
|
||||
MAPS.path = Contents/Resources
|
||||
MAPS.files = pkg/maps
|
||||
ICONS.path = Contents/Resources/icons
|
||||
ICONS.files = icons/tcx.icns \
|
||||
icons/kml.icns \
|
||||
icons/fit.icns \
|
||||
icons/igc.icns \
|
||||
icons/nmea.icns \
|
||||
pkg/maps.txt \
|
||||
pkg/ellipsoids.csv \
|
||||
pkg/datums.csv
|
||||
APP_RESOURCES.path = Contents/Resources
|
||||
QMAKE_BUNDLE_DATA += APP_RESOURCES
|
||||
icons/nmea.icns
|
||||
QMAKE_BUNDLE_DATA += LOCALE MAPS ICONS CSV
|
||||
}
|
||||
win32 {
|
||||
RC_ICONS = icons/gpxsee.ico \
|
||||
|
@ -20,8 +20,5 @@
|
||||
<file>icons/system-run.png</file>
|
||||
<file>icons/document-print-preview.png</file>
|
||||
<file>icons/view-filter.png</file>
|
||||
<file>lang/gpxsee_cs.qm</file>
|
||||
<file>lang/gpxsee_sv.qm</file>
|
||||
<file>lang/gpxsee_de.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1564
lang/gpxsee_fi.ts
Normal file
1564
lang/gpxsee_fi.ts
Normal file
File diff suppressed because it is too large
Load Diff
1564
lang/gpxsee_fr.ts
Normal file
1564
lang/gpxsee_fr.ts
Normal file
File diff suppressed because it is too large
Load Diff
1565
lang/gpxsee_ru.ts
Normal file
1565
lang/gpxsee_ru.ts
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@
|
||||
<string>application/gpx+xml</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>gpx.icns</string>
|
||||
<string>icons/gpx.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>GPS Exchange Format</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
@ -45,7 +45,7 @@
|
||||
<string>application/tcx+xml</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>tcx.icns</string>
|
||||
<string>icons/tcx.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Training Center XML</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
@ -61,7 +61,7 @@
|
||||
<string>application/vnd.google-earth.kml+xml</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>kml.icns</string>
|
||||
<string>icons/kml.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Keyhole Markup Language</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
@ -77,7 +77,7 @@
|
||||
<string>application/vnd.ant.fit</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>fit.icns</string>
|
||||
<string>icons/fit.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Flexible and Interoperable Data Transfer</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
@ -93,7 +93,7 @@
|
||||
<string>application/vnd.fai.igc</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>igc.icns</string>
|
||||
<string>icons/igc.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Flight Recorder Data Format</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
@ -109,7 +109,7 @@
|
||||
<string>application/vnd.nmea.nmea</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>nmea.icns</string>
|
||||
<string>icons/nmea.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>NMEA 0183 data</string>
|
||||
<key>CFBundleTypeRole</key>
|
19
pkg/csv/ellipsoids.csv
Normal file
19
pkg/csv/ellipsoids.csv
Normal file
@ -0,0 +1,19 @@
|
||||
Airy 1830,7001,6377563.396,299.3249646
|
||||
Modified Airy,7002,6377340.189,299.3249646
|
||||
Australian National,7003,6378160.0,298.25
|
||||
Bessel 1841,7004,6377397.155,299.1528128
|
||||
Bessel 1841 (Norway),7005,6377492.0176,299.1528
|
||||
Clarke 1866,7008,6378206.4,294.9786982
|
||||
Clarke 1880 (Palestine),7010,6378300.789,293.466
|
||||
Clarke 1880 (IGN),7011,6378249.2,293.466021
|
||||
Clarke 1880,7012,6378249.145,293.465
|
||||
Everest 1830 (1937 Adjustment),7015,6377276.345,300.8017
|
||||
Everest 1830 Modified,7018,6377304.063,300.8017
|
||||
GRS 80,7019,6378137.0,298.257222101
|
||||
Helmert 1906,7020,6378200.0,298.3
|
||||
International 1924,7022,6378388.0,297.0
|
||||
Krassovsky 1940,7024,6378245.0,298.3
|
||||
South American 1969,7036,6378160.0,298.25
|
||||
WGS 72,7043,6378135.0,298.26
|
||||
Bessel 1841 (Namibia),7046,6377483.865,299.1528128
|
||||
Hough 1960,7053,6378270.0,297.0
|
|
121
pkg/csv/gcs.csv
Normal file
121
pkg/csv/gcs.csv
Normal file
@ -0,0 +1,121 @@
|
||||
Adindan,4201,6201,9122,7012,8901,9603,-162,-12,206
|
||||
Afgooye,4205,6205,9122,7024,8901,9603,-43,-163,45
|
||||
Ain el Abd 1970,4204,6204,9122,7022,8901,9603,-150,-251,-2
|
||||
Anna 1 Astro 1965,4708,6708,9122,7003,8901,9603,-491,-22,435
|
||||
Arc 1950,4209,6209,9122,7012,8901,9603,-143,-90,-294
|
||||
Arc 1960,4210,6210,9122,7012,8901,9603,-160,-8,-300
|
||||
Ascension Island 1958,4712,6712,9122,7022,8901,9603,-207,107,52
|
||||
Astro B4 Sorol Atoll,4707,6707,9122,7022,8901,9603,114,-116,-333
|
||||
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
|
||||
Australian Geodetic 1966,4202,6202,9122,7003,8901,9603,-133,-48,148
|
||||
Australian Geodetic 1984,4203,6203,9122,7003,8901,9603,-134,-48,149
|
||||
Australian Geocentric 1994 (GDA94),4283,6283,9122,7019,8901,9603,0,0,0
|
||||
Austrian,4312,6312,9122,7004,8901,9603,594,84,471
|
||||
Bellevue (IGN),4714,6714,9122,7022,8901,9603,-127,-769,472
|
||||
Bermuda 1957,4216,6216,9122,7008,8901,9603,-73,213,296
|
||||
Bogota Observatory,4218,6218,9122,7022,8901,9603,307,304,-318
|
||||
Campo Inchauspe,4221,6221,9122,7022,8901,9603,-148,136,90
|
||||
Canton Astro 1966,4716,6716,9122,7022,8901,9603,298,-304,-375
|
||||
Cape,4222,6222,9122,7012,8901,9603,-136,-108,-292
|
||||
Cape Canaveral,4717,6717,9122,7008,8901,9603,-2,150,181
|
||||
Carthage,4223,6223,9122,7012,8901,9603,-263,6,431
|
||||
CH-1903,4149,6149,9122,7004,8901,9603,674,15,405
|
||||
Chatham 1971,4672,6672,9122,7022,8901,9603,175,-38,113
|
||||
Chua Astro,4224,6224,9122,7022,8901,9603,-134,229,-29
|
||||
Corrego Alegre,4225,6225,9122,7022,8901,9603,-206,172,-6
|
||||
Djakarta (Batavia),4211,6211,9122,7004,8901,9603,-377,681,-50
|
||||
DOS 1968,,,9122,7022,8901,9603,230,-199,-752
|
||||
Easter Island 1967,4719,6719,9122,7022,8901,9603,211,147,111
|
||||
Egypt,4199,6199,9122,7022,8901,9603,-130,-117,-151
|
||||
European 1950,4230,6230,9122,7022,8901,9603,-87,-98,-121
|
||||
European 1950 (Mean France),,,9122,7022,8901,9603,-87,-96,-120
|
||||
European 1950 (Spain and Portugal),,,9122,7022,8901,9603,-84,-107,-120
|
||||
European 1979,4668,6668,9122,7022,8901,9603,-86,-98,-119
|
||||
Finland Hayford,4123,6123,9122,7022,8901,9603,-78,-231,-97
|
||||
Gandajika Base,4233,6233,9122,7022,8901,9603,-133,-321,50
|
||||
Geodetic Datum 1949,4272,6272,9122,7022,8901,9603,84,-22,209
|
||||
GGRS 87,4121,6121,9122,7019,8901,9603,-199.87,74.79,246.62
|
||||
Guam 1963,4675,6675,9122,7008,8901,9603,-100,-248,259
|
||||
GUX 1 Astro,4718,6718,9122,7022,8901,9603,252,-209,-751
|
||||
Hartebeeshoek94,4148,6148,9122,7030,8901,9603,0,0,0
|
||||
Hermannskogel,3906,1031,9122,7004,8901,9603,653,-212,449
|
||||
Hjorsey 1955,4658,6658,9122,7022,8901,9603,-73,46,-86
|
||||
Hong Kong 1963,4739,6739,9122,7022,8901,9603,-156,-271,-189
|
||||
Hu-Tzu-Shan,4236,6236,9122,7022,8901,9603,-634,-549,-201
|
||||
Indian Bangladesh,4682,6682,9122,7015,8901,9603,289,734,257
|
||||
Indian Thailand,4240,6240,9122,7015,8901,9603,214,836,303
|
||||
Israeli,4281,6281,9122,7010,8901,9603,-235,-85,264
|
||||
Ireland 1965,4299,6299,9122,7002,8901,9603,506,-122,611
|
||||
ISTS 073 Astro 1969,4724,6724,9122,7022,8901,9603,208,-435,-229
|
||||
Johnston Island,4725,6725,9122,7022,8901,9603,191,-77,-204
|
||||
Kandawala,4244,6244,9122,7015,8901,9603,-97,787,86
|
||||
Kerguelen Island,4698,6698,9122,7022,8901,9603,145,-187,103
|
||||
Kertau 1948,4245,6245,9122,7018,8901,9603,-11,851,5
|
||||
L.C. 5 Astro,4726,6726,9122,7008,8901,9603,42,124,147
|
||||
Liberia 1964,4251,6251,9122,7012,8901,9603,-90,40,88
|
||||
Luzon Mindanao,,,9122,7008,8901,9603,-133,-79,-72
|
||||
Luzon Philippines,4253,6253,9122,7008,8901,9603,-133,-77,-51
|
||||
Mahe 1971,4256,6256,9122,7012,8901,9603,41,-220,-134
|
||||
Marco Astro,4616,6616,9122,7022,8901,9603,-289,-124,60
|
||||
Massawa,4262,6262,9122,7004,8901,9603,639,405,60
|
||||
Merchich,4261,6261,9122,7012,8901,9603,31,146,47
|
||||
Midway Astro 1961,4727,6727,9122,7022,8901,9603,912,-58,1227
|
||||
Minna,4263,6263,9122,7012,8901,9603,-92,-93,122
|
||||
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 CONUS,4267,6267,9122,7008,8901,9603,-8,160,176
|
||||
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
|
||||
NAD83,4269,6269,9122,7019,8901,9603,0,0,0
|
||||
Nahrwn Masirah Ilnd,,,9122,7012,8901,9603,-247,-148,369
|
||||
Nahrwn Saudi Arbia,,,9122,7012,8901,9603,-231,-196,482
|
||||
Nahrwn United Arab,4270,6270,9122,7012,8901,9603,-249,-156,381
|
||||
Naparima BWI,4271,6271,9122,7022,8901,9603,-2,374,172
|
||||
NGO1948,4273,6273,9122,7005,8901,9603,315,-217,528
|
||||
NTF France,4275,6275,9122,7011,8901,9603,-168,-60,320
|
||||
Norsk,4817,6817,9122,7005,8913,9603,278,93,474
|
||||
NZGD1949,4272,6272,9122,7022,8901,9603,84,-22,209
|
||||
NZGD2000,4167,6167,9122,7030,8901,9603,0,0,0
|
||||
Observatorio 1966,4182,6182,9122,7022,8901,9603,-425,-169,81
|
||||
Old Egyptian,4229,6229,9122,7020,8901,9603,-130,110,-13
|
||||
Old Hawaiian,4135,6135,9122,7008,8901,9603,61,-285,-181
|
||||
Oman,4232,6232,9122,7012,8901,9603,-346,-1,224
|
||||
Ord Srvy Grt Britn,4277,6277,9122,7001,8901,9603,375,-111,431
|
||||
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
|
||||
Potsdam Rauenberg DHDN,4314,6314,9122,7004,8901,9603,606,23,413
|
||||
Prov So Amrican 1956,4248,6248,9122,7022,8901,9603,-288,175,-376
|
||||
Prov So Chilean 1963,4254,6254,9122,7022,8901,9603,16,196,93
|
||||
Puerto Rico,4139,6139,9122,7008,8901,9603,11,72,-101
|
||||
Pulkovo 1942 (1),4284,6284,9122,7024,8901,9603,28,-130,-95
|
||||
Pulkovo 1942 (2),,,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
|
||||
Reunion,4626,6626,9122,7022,8901,9603,94,-948,-1262
|
||||
Rijksdriehoeksmeting,4289,6289,9122,7004,8901,9603,593,26,478
|
||||
Rome 1940,4806,6806,9122,7022,8906,9603,-225,-65,9
|
||||
RT 90,4124,6124,9122,7004,8901,9603,498,-36,568
|
||||
S42,4179,6179,9122,7024,8901,9603,28,-121,-77
|
||||
Santo (DOS),4730,6730,9122,7022,8901,9603,170,42,84
|
||||
Sao Braz,4184,6184,9122,7022,8901,9603,-203,141,53
|
||||
Sapper Hill 1943,4292,6292,9122,7022,8901,9603,-355,16,74
|
||||
Schwarzeck,4293,6293,9122,7046,8901,9603,616,97,-251
|
||||
South American 1969,4291,6291,9108,7036,8901,9603,-57,1,-41
|
||||
Southeast Base,4615,6615,9122,7022,8901,9603,-499,-249,314
|
||||
Southwest Base,4183,6183,9122,7022,8901,9603,-104,167,-38
|
||||
Timbalai 1948,4298,6298,9122,7015,8901,9603,-689,691,-46
|
||||
Tokyo,4301,6301,9122,7004,8901,9603,-128,481,664
|
||||
Tristan Astro 1968,4734,6734,9122,7022,8901,9603,-632,438,-609
|
||||
Viti Levu 1916,4731,6731,9122,7012,8901,9603,51,391,-36
|
||||
Wake-Eniwetok 1960,4732,6732,9122,7053,8901,9603,101,52,-39
|
||||
WGS 72,4322,6322,9122,7043,8901,9603,0,0,5
|
||||
Yacare,4309,6309,9122,7022,8901,9603,-155,171,37
|
||||
Zanderij,4311,6311,9122,7022,8901,9603,-265,120,-358
|
|
1626
pkg/csv/pcs.csv
Normal file
1626
pkg/csv/pcs.csv
Normal file
File diff suppressed because it is too large
Load Diff
123
pkg/datums.csv
123
pkg/datums.csv
@ -1,123 +0,0 @@
|
||||
Adindan,4201,5,-162,-12,206
|
||||
Afgooye,4205,15,-43,-163,45
|
||||
Ain el Abd 1970,4204,14,-150,-251,-2
|
||||
Anna 1 Astro 1965,4708,2,-491,-22,435
|
||||
Arc 1950,4209,5,-143,-90,-294
|
||||
Arc 1960,4210,5,-160,-8,-300
|
||||
Ascension Island 1958,4712,14,-207,107,52
|
||||
Astro B4 Sorol Atoll,4707,14,114,-116,-333
|
||||
Astro Beacon 1945,4709,14,145,75,-272
|
||||
Astro DOS 71/4,4710,14,-320,550,-494
|
||||
Astronomic Stn 1952,4711,14,124,-234,-25
|
||||
Australian Geodetic 1966,4202,2,-133,-48,148
|
||||
Australian Geodetic 1984,4203,2,-134,-48,149
|
||||
Australian Geocentric 1994 (GDA94),4283,11,0,0,0
|
||||
Austrian,4312,3,594,84,471
|
||||
Bellevue (IGN),4714,14,-127,-769,472
|
||||
Bermuda 1957,4216,4,-73,213,296
|
||||
Bogota Observatory,4218,14,307,304,-318
|
||||
Campo Inchauspe,4221,14,-148,136,90
|
||||
Canton Astro 1966,4716,14,298,-304,-375
|
||||
Cape,4222,5,-136,-108,-292
|
||||
Cape Canaveral,4717,4,-2,150,181
|
||||
Carthage,4223,5,-263,6,431
|
||||
CH-1903,4149,3,674,15,405
|
||||
Chatham 1971,4672,14,175,-38,113
|
||||
Chua Astro,4224,14,-134,229,-29
|
||||
Corrego Alegre,4225,14,-206,172,-6
|
||||
Djakarta (Batavia),4211,3,-377,681,-50
|
||||
DOS 1968,,14,230,-199,-752
|
||||
Easter Island 1967,4719,14,211,147,111
|
||||
Egypt,,14,-130,-117,-151
|
||||
European 1950,4230,14,-87,-98,-121
|
||||
European 1950 (Mean France),,14,-87,-96,-120
|
||||
European 1950 (Spain and Portugal),,14,-84,-107,-120
|
||||
European 1979,4668,14,-86,-98,-119
|
||||
Finland Hayford,4123,14,-78,-231,-97
|
||||
Gandajika Base,4233,14,-133,-321,50
|
||||
Geodetic Datum 1949,4272,14,84,-22,209
|
||||
GGRS 87,4121,11,-199.87,74.79,246.62
|
||||
Guam 1963,4675,4,-100,-248,259
|
||||
GUX 1 Astro,4718,14,252,-209,-751
|
||||
Hartebeeshoek94,4148,20,0,0,0
|
||||
Hermannskogel,3906,3,653,-212,449
|
||||
Hjorsey 1955,4658,14,-73,46,-86
|
||||
Hong Kong 1963,4739,14,-156,-271,-189
|
||||
Hu-Tzu-Shan,4236,14,-634,-549,-201
|
||||
Indian Bangladesh,4682,6,289,734,257
|
||||
Indian Thailand,4240,6,214,836,303
|
||||
Israeli,4281,23,-235,-85,264
|
||||
Ireland 1965,4299,1,506,-122,611
|
||||
ISTS 073 Astro 1969,4724,14,208,-435,-229
|
||||
Johnston Island,4725,14,191,-77,-204
|
||||
Kandawala,4244,6,-97,787,86
|
||||
Kerguelen Island,4698,14,145,-187,103
|
||||
Kertau 1948,4245,7,-11,851,5
|
||||
L.C. 5 Astro,4726,4,42,124,147
|
||||
Liberia 1964,4251,5,-90,40,88
|
||||
Luzon Mindanao,,4,-133,-79,-72
|
||||
Luzon Philippines,4253,4,-133,-77,-51
|
||||
Mahe 1971,4256,5,41,-220,-134
|
||||
Marco Astro,4616,14,-289,-124,60
|
||||
Massawa,4262,3,639,405,60
|
||||
Merchich,4261,5,31,146,47
|
||||
Midway Astro 1961,4727,14,912,-58,1227
|
||||
Minna,4263,5,-92,-93,122
|
||||
NAD27 Alaska,,4,-5,135,172
|
||||
NAD27 Bahamas,,4,-4,154,178
|
||||
NAD27 Canada,,4,-10,158,187
|
||||
NAD27 Canal Zone,,4,0,125,201
|
||||
NAD27 Caribbean,,4,-7,152,178
|
||||
NAD27 Central,,4,0,125,194
|
||||
NAD27 CONUS,,4,-8,160,176
|
||||
NAD27 Cuba,,4,-9,152,178
|
||||
NAD27 Greenland,,4,11,114,195
|
||||
NAD27 Mexico,,4,-12,130,190
|
||||
NAD27 San Salvador,,4,1,140,165
|
||||
NAD83,4269,11,0,0,0
|
||||
Nahrwn Masirah Ilnd,,5,-247,-148,369
|
||||
Nahrwn Saudi Arbia,,5,-231,-196,482
|
||||
Nahrwn United Arab,,5,-249,-156,381
|
||||
Naparima BWI,4271,14,-2,374,172
|
||||
NGO1948,4273,27,315,-217,528
|
||||
NTF France,4275,24,-168,-60,320
|
||||
Norsk,4817,27,278,93,474
|
||||
NZGD1949,4272,14,84,-22,209
|
||||
NZGD2000,4167,20,0,0,0
|
||||
Observatorio 1966,4182,14,-425,-169,81
|
||||
Old Egyptian,4229,12,-130,110,-13
|
||||
Old Hawaiian,4135,4,61,-285,-181
|
||||
Oman,4232,5,-346,-1,224
|
||||
Ord Srvy Grt Britn,4277,0,375,-111,431
|
||||
Pico De Las Nieves,4728,14,-307,-92,127
|
||||
Pitcairn Astro 1967,4729,14,185,165,42
|
||||
Potsdam Rauenberg DHDN,4314,3,606,23,413
|
||||
Prov So Amrican 1956,4248,14,-288,175,-376
|
||||
Prov So Chilean 1963,4254,14,16,196,93
|
||||
Puerto Rico,4139,4,11,72,-101
|
||||
Pulkovo 1942 (1),4284,15,28,-130,-95
|
||||
Pulkovo 1942 (2),4284,15,28,-130,-95
|
||||
Qatar National,4285,14,-128,-283,22
|
||||
Qornoq,4287,14,164,138,-189
|
||||
Reunion,4626,14,94,-948,-1262
|
||||
Rijksdriehoeksmeting,4289,3,593,26,478
|
||||
Rome 1940,4806,14,-225,-65,9
|
||||
RT 90,4124,3,498,-36,568
|
||||
S42,4179,15,28,-121,-77
|
||||
Santo (DOS),4730,14,170,42,84
|
||||
Sao Braz,4184,14,-203,141,53
|
||||
Sapper Hill 1943,4292,14,-355,16,74
|
||||
Schwarzeck,4293,21,616,97,-251
|
||||
South American 1969,4291,16,-57,1,-41
|
||||
South Asia,,8,7,-10,-26
|
||||
Southeast Base,4615,14,-499,-249,314
|
||||
Southwest Base,4183,14,-104,167,-38
|
||||
Timbalai 1948,4298,6,-689,691,-46
|
||||
Tokyo,4301,3,-128,481,664
|
||||
Tristan Astro 1968,4734,14,-632,438,-609
|
||||
Viti Levu 1916,4731,5,51,391,-36
|
||||
Wake-Eniwetok 1960,4732,13,101,52,-39
|
||||
WGS 72,4322,19,0,0,5
|
||||
WGS 84,4326,20,0,0,0
|
||||
Yacare,4309,14,-155,171,37
|
||||
Zanderij,4311,14,-265,120,-358
|
|
@ -1,30 +0,0 @@
|
||||
0,Airy 1830,6377563.396,299.3249646
|
||||
1,Modified Airy,6377340.189,299.3249646
|
||||
2,Australian National,6378160.0,298.25
|
||||
3,Bessel 1841,6377397.155,299.1528128
|
||||
4,Clarke 1866,6378206.4,294.9786982
|
||||
5,Clarke 1880,6378249.145,293.465
|
||||
6,Everest (India 1830),6377276.345,300.8017
|
||||
7,Everest (1948),6377304.063,300.8017
|
||||
8,Modified Fischer 1960,6378155.0,298.3
|
||||
9,Everest (Pakistan),6377309.613,300.8017
|
||||
10,Indonesian 1974,6378160.0,298.247
|
||||
11,GRS 80,6378137.0,298.257222101
|
||||
12,Helmert 1906,6378200.0,298.3
|
||||
13,Hough 1960,6378270.0,297.0
|
||||
14,International 1924,6378388.0,297.0
|
||||
15,Krassovsky 1940,6378245.0,298.3
|
||||
16,South American 1969,6378160.0,298.25
|
||||
17,Everest (Malaysia 1969),6377295.664,300.8017
|
||||
18,Everest (Sabah Sarawak),6377298.556,300.8017
|
||||
19,WGS 72,6378135.0,298.26
|
||||
20,WGS 84,6378137.0,298.257223563
|
||||
21,Bessel 1841 (Namibia),6377483.865,299.1528128
|
||||
22,Everest (India 1956),6377301.243,300.8017
|
||||
23,Clarke 1880 Palestine,6378300.789,293.466
|
||||
24,Clarke 1880 IGN,6378249.2,293.466021
|
||||
25,Hayford 1909,6378388.0,296.959263
|
||||
26,Clarke 1858,6378350.87,294.26
|
||||
27,Bessel 1841 (Norway),6377492.0176,299.1528
|
||||
28,Plessis 1817 (France),6376523.0,308.6409971
|
||||
29,Hayford 1924,6378388.0,297.0
|
|
12
pkg/gpxsee.desktop
Normal file
12
pkg/gpxsee.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Name=GPXSee
|
||||
Comment=GPS log file viewer and analyzer
|
||||
Comment[cz]=Prohlížeč a analyzátor GPS logů
|
||||
Comment[fi]=Ohjelma GPS-lokien katseluun ja analysointiin
|
||||
Comment[ru]=Программа для просмотра и анализа GPS логов
|
||||
Exec=gpxsee %F
|
||||
Icon=gpxsee
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Graphics;Viewer;Maps;Qt;
|
||||
MimeType=application/gpx+xml;application/tcx+xml;application/vnd.ant.fit;application/vnd.google-earth.kml+xml;application/vnd.fai.igc;application/vnd.nmea.nmea;
|
@ -5,7 +5,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "4.17"
|
||||
!define VERSION "5.1"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}.exe"
|
||||
@ -83,9 +83,8 @@ Section "GPXSee" SEC_APP
|
||||
|
||||
; Put the files there
|
||||
File "gpxsee.exe"
|
||||
File "maps.txt"
|
||||
File "ellipsoids.csv"
|
||||
File "datums.csv"
|
||||
File /r "maps"
|
||||
File /r "csv"
|
||||
|
||||
; Create start menu entry and add links
|
||||
SetShellVarContext all
|
||||
@ -195,6 +194,38 @@ Section "ANGLE" SEC_ANGLE
|
||||
|
||||
SectionEnd
|
||||
|
||||
SectionGroup "Localization" SEC_LOCALIZATION
|
||||
Section "Czech"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_cs.qm translations\gpxsee_cs.qm
|
||||
File /oname=translations\qt_cs.qm translations\qt_cs.qm
|
||||
SectionEnd
|
||||
Section "Finnish"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_fi.qm translations\gpxsee_fi.qm
|
||||
File /oname=translations\qt_fi.qm translations\qt_fi.qm
|
||||
SectionEnd
|
||||
Section "French"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_fr.qm translations\gpxsee_fr.qm
|
||||
File /oname=translations\qt_fr.qm translations\qt_fr.qm
|
||||
SectionEnd
|
||||
Section "German"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_de.qm translations\gpxsee_de.qm
|
||||
File /oname=translations\qt_de.qm translations\qt_de.qm
|
||||
SectionEnd
|
||||
Section "Russian"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_ru.qm translations\gpxsee_ru.qm
|
||||
File /oname=translations\qt_ru.qm translations\qt_ru.qm
|
||||
SectionEnd
|
||||
Section "Swedish"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_sv.qm translations\gpxsee_sv.qm
|
||||
SectionEnd
|
||||
SectionGroupEnd
|
||||
|
||||
;--------------------------------
|
||||
|
||||
; Uninstaller
|
||||
@ -246,6 +277,8 @@ LangString DESC_ANGLE ${LANG_ENGLISH} \
|
||||
"ANGLE (OpenGL via Direct3D). Enables OpenGL on systems without native OpenGL drivers."
|
||||
LangString DESC_APP ${LANG_ENGLISH} \
|
||||
"GPXSee application"
|
||||
LangString DESC_LOCALIZATION ${LANG_ENGLISH} \
|
||||
"Localization"
|
||||
|
||||
;Assign language strings to sections
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||
@ -254,4 +287,5 @@ LangString DESC_APP ${LANG_ENGLISH} \
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_ANGLE} $(DESC_ANGLE)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_LOCALIZATION} $(DESC_LOCALIZATION)
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
|
46
pkg/gpxsee.xml
Normal file
46
pkg/gpxsee.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
||||
|
||||
<mime-type type="application/gpx+xml">
|
||||
<comment>GPS Exchange Format</comment>
|
||||
<sub-class-of type="application/xml"/>
|
||||
<generic-icon name="application-xml"/>
|
||||
<glob pattern="*.gpx"/>
|
||||
</mime-type>
|
||||
|
||||
<mime-type type="application/tcx+xml">
|
||||
<comment>Training Center XML</comment>
|
||||
<sub-class-of type="application/xml"/>
|
||||
<generic-icon name="application-xml"/>
|
||||
<glob pattern="*.tcx"/>
|
||||
</mime-type>
|
||||
|
||||
<mime-type type="application/kml+xml">
|
||||
<comment>Keyhole Markup Language</comment>
|
||||
<sub-class-of type="application/xml"/>
|
||||
<generic-icon name="application-xml"/>
|
||||
<glob pattern="*.kml"/>
|
||||
</mime-type>
|
||||
|
||||
<mime-type type="application/vnd.ant.fit">
|
||||
<comment>Flexible and Interoperable Data Transfer</comment>
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<generic-icon name="application-octet-stream"/>
|
||||
<glob pattern="*.fit"/>
|
||||
</mime-type>
|
||||
|
||||
<mime-type type="application/vnd.fai.igc">
|
||||
<comment>Flight Recorder Data Format</comment>
|
||||
<sub-class-of type="text/plain"/>
|
||||
<generic-icon name="text-plain"/>
|
||||
<glob pattern="*.igc"/>
|
||||
</mime-type>
|
||||
|
||||
<mime-type type="application/vnd.nmea.nmea">
|
||||
<comment>NMEA 0183 data</comment>
|
||||
<sub-class-of type="text/plain"/>
|
||||
<generic-icon name="text-plain"/>
|
||||
<glob pattern="*.nmea"/>
|
||||
</mime-type>
|
||||
|
||||
</mime-info>
|
@ -5,7 +5,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "4.17"
|
||||
!define VERSION "5.1"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
@ -90,9 +90,8 @@ Section "GPXSee" SEC_APP
|
||||
|
||||
; Put the files there
|
||||
File "gpxsee.exe"
|
||||
File "maps.txt"
|
||||
File "ellipsoids.csv"
|
||||
File "datums.csv"
|
||||
File /r "maps"
|
||||
File /r "csv"
|
||||
|
||||
; Create start menu entry and add links
|
||||
SetShellVarContext all
|
||||
@ -197,6 +196,38 @@ Section "ANGLE" SEC_ANGLE
|
||||
|
||||
SectionEnd
|
||||
|
||||
SectionGroup "Localization" SEC_LOCALIZATION
|
||||
Section "Czech"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_cs.qm translations\gpxsee_cs.qm
|
||||
File /oname=translations\qt_cs.qm translations\qt_cs.qm
|
||||
SectionEnd
|
||||
Section "Finnish"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_fi.qm translations\gpxsee_fi.qm
|
||||
File /oname=translations\qt_fi.qm translations\qt_fi.qm
|
||||
SectionEnd
|
||||
Section "French"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_fr.qm translations\gpxsee_fr.qm
|
||||
File /oname=translations\qt_fr.qm translations\qt_fr.qm
|
||||
SectionEnd
|
||||
Section "German"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_de.qm translations\gpxsee_de.qm
|
||||
File /oname=translations\qt_de.qm translations\qt_de.qm
|
||||
SectionEnd
|
||||
Section "Russian"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_ru.qm translations\gpxsee_ru.qm
|
||||
File /oname=translations\qt_ru.qm translations\qt_ru.qm
|
||||
SectionEnd
|
||||
Section "Swedish"
|
||||
CreateDirectory "$INSTDIR\translations"
|
||||
File /oname=translations\gpxsee_sv.qm translations\gpxsee_sv.qm
|
||||
SectionEnd
|
||||
SectionGroupEnd
|
||||
|
||||
;--------------------------------
|
||||
|
||||
; Uninstaller
|
||||
@ -249,6 +280,8 @@ LangString DESC_ANGLE ${LANG_ENGLISH} \
|
||||
"ANGLE (OpenGL via Direct3D). Enables OpenGL on systems without native OpenGL drivers."
|
||||
LangString DESC_APP ${LANG_ENGLISH} \
|
||||
"GPXSee application"
|
||||
LangString DESC_LOCALIZATION ${LANG_ENGLISH} \
|
||||
"Localization"
|
||||
|
||||
;Assign language strings to sections
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||
@ -257,4 +290,5 @@ LangString DESC_APP ${LANG_ENGLISH} \
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_ANGLE} $(DESC_ANGLE)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_LOCALIZATION} $(DESC_LOCALIZATION)
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
|
@ -1,5 +0,0 @@
|
||||
Open Topo Map https://a.tile.opentopomap.org/$z/$x/$y.png 17
|
||||
4UMaps http://4umaps.eu/$z/$x/$y.png 15
|
||||
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png 19
|
||||
USGS Topo https://navigator.er.usgs.gov/tiles/tcr.cgi/$z/$x/$y.png 15
|
||||
USGS Imagery https://navigator.er.usgs.gov/tiles/aerial_Imagery.cgi/$z/$x/$y 15
|
7
pkg/maps/4UMaps.xml
Normal file
7
pkg/maps/4UMaps.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map>
|
||||
<name>4UMaps</name>
|
||||
<url>http://4umaps.eu/$z/$x/$y.png</url>
|
||||
<zoom min="2" max="15"/>
|
||||
<bounds bottom="-65"/>
|
||||
</map>
|
5
pkg/maps/OpenStreetMap.xml
Normal file
5
pkg/maps/OpenStreetMap.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map>
|
||||
<name>Open Street Map</name>
|
||||
<url>http://tile.openstreetmap.org/$z/$x/$y.png</url>
|
||||
</map>
|
6
pkg/maps/OpenTopoMap.xml
Normal file
6
pkg/maps/OpenTopoMap.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map>
|
||||
<name>Open Topo Map</name>
|
||||
<url>https://a.tile.opentopomap.org/$z/$x/$y.png</url>
|
||||
<zoom max="17"/>
|
||||
</map>
|
7
pkg/maps/USGS-imagery.xml
Normal file
7
pkg/maps/USGS-imagery.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map>
|
||||
<name>USGS Imagery</name>
|
||||
<url>https://navigator.er.usgs.gov/tiles/aerial_Imagery.cgi/$z/$x/$y</url>
|
||||
<zoom min="2" max="15"/>
|
||||
<bounds bottom="0" top="74"/>
|
||||
</map>
|
6
pkg/maps/USGS-topo.xml
Normal file
6
pkg/maps/USGS-topo.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map>
|
||||
<name>USGS Topo</name>
|
||||
<url>https://navigator.er.usgs.gov/tiles/tcr.cgi/$z/$x/$y.png</url>
|
||||
<zoom min="2" max="15"/>
|
||||
</map>
|
@ -7,7 +7,8 @@
|
||||
#include "map/onlinemap.h"
|
||||
#include "map/downloader.h"
|
||||
#include "map/ellipsoid.h"
|
||||
#include "map/datum.h"
|
||||
#include "map/gcs.h"
|
||||
#include "map/pcs.h"
|
||||
#include "opengl.h"
|
||||
#include "gui.h"
|
||||
#include "config.h"
|
||||
@ -18,13 +19,16 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||
_argc(argc), _argv(argv)
|
||||
{
|
||||
QTranslator *gpxsee = new QTranslator(this);
|
||||
QString locale = QLocale::system().name();
|
||||
gpxsee->load(QString(":/lang/gpxsee_") + locale);
|
||||
gpxsee->load(QLocale::system(), "gpxsee", "_", TRANSLATIONS_DIR);
|
||||
installTranslator(gpxsee);
|
||||
|
||||
QTranslator *qt = new QTranslator(this);
|
||||
#if defined(Q_OS_WINDOWS) || defined(Q_OS_MAC)
|
||||
qt->load(QLocale::system(), "qt", "_", TRANSLATIONS_DIR);
|
||||
#else // Q_OS_WINDOWS || Q_OS_MAC
|
||||
qt->load(QLocale::system(), "qt", "_", QLibraryInfo::location(
|
||||
QLibraryInfo::TranslationsPath));
|
||||
#endif // Q_OS_WINDOWS || Q_OS_MAC
|
||||
installTranslator(qt);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
@ -35,6 +39,7 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||
OnlineMap::setDownloader(new Downloader(this));
|
||||
OPENGL_SET_SAMPLES(4);
|
||||
loadDatums();
|
||||
loadPCSs();
|
||||
|
||||
_gui = new GUI();
|
||||
}
|
||||
@ -67,7 +72,6 @@ bool App::event(QEvent *event)
|
||||
void App::loadDatums()
|
||||
{
|
||||
QString ef, df;
|
||||
bool ok = false;
|
||||
|
||||
if (QFile::exists(USER_ELLIPSOID_FILE))
|
||||
ef = USER_ELLIPSOID_FILE;
|
||||
@ -76,34 +80,32 @@ void App::loadDatums()
|
||||
else
|
||||
qWarning("No ellipsoids file found.");
|
||||
|
||||
if (QFile::exists(USER_DATUM_FILE))
|
||||
df = USER_DATUM_FILE;
|
||||
else if (QFile::exists(GLOBAL_DATUM_FILE))
|
||||
df = GLOBAL_DATUM_FILE;
|
||||
if (QFile::exists(USER_GCS_FILE))
|
||||
df = USER_GCS_FILE;
|
||||
else if (QFile::exists(GLOBAL_GCS_FILE))
|
||||
df = GLOBAL_GCS_FILE;
|
||||
else
|
||||
qWarning("No datums file found.");
|
||||
|
||||
if (!ef.isNull() && !df.isNull()) {
|
||||
if (!Ellipsoid::loadList(ef)) {
|
||||
if (Ellipsoid::errorLine())
|
||||
qWarning("%s: parse error on line %d: %s", qPrintable(ef),
|
||||
Ellipsoid::errorLine(), qPrintable(Ellipsoid::errorString()));
|
||||
else
|
||||
qWarning("%s: %s", qPrintable(ef), qPrintable(
|
||||
Ellipsoid::errorString()));
|
||||
} else {
|
||||
if (!Datum::loadList(df)) {
|
||||
if (Datum::errorLine())
|
||||
qWarning("%s: parse error on line %d: %s", qPrintable(ef),
|
||||
Datum::errorLine(), qPrintable(Datum::errorString()));
|
||||
else
|
||||
qWarning("%s: %s", qPrintable(ef), qPrintable(
|
||||
Datum::errorString()));
|
||||
Ellipsoid::loadList(ef);
|
||||
GCS::loadList(df);
|
||||
} else
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
qWarning("Maps based on a datum different from WGS84 won't work.");
|
||||
}
|
||||
|
||||
void App::loadPCSs()
|
||||
{
|
||||
QString file;
|
||||
|
||||
if (QFile::exists(USER_PCS_FILE))
|
||||
file = USER_PCS_FILE;
|
||||
else if (QFile::exists(GLOBAL_PCS_FILE))
|
||||
file = GLOBAL_PCS_FILE;
|
||||
else {
|
||||
qWarning("No PCS file found.");
|
||||
return;
|
||||
}
|
||||
|
||||
PCS::loadList(file);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ protected:
|
||||
|
||||
private:
|
||||
void loadDatums();
|
||||
void loadPCSs();
|
||||
|
||||
int &_argc;
|
||||
char **_argv;
|
||||
|
@ -62,12 +62,17 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
||||
_bottomMargin = new QDoubleSpinBox();
|
||||
_leftMargin = new QDoubleSpinBox();
|
||||
_rightMargin = new QDoubleSpinBox();
|
||||
QString us = (_export->units == Imperial) ? tr("in") : tr("mm");
|
||||
QString us = (_export->units == Metric) ? tr("mm") : tr("in");
|
||||
_topMargin->setSuffix(UNIT_SPACE + us);
|
||||
_bottomMargin->setSuffix(UNIT_SPACE + us);
|
||||
_leftMargin->setSuffix(UNIT_SPACE + us);
|
||||
_rightMargin->setSuffix(UNIT_SPACE + us);
|
||||
if (_export->units == Imperial) {
|
||||
if (_export->units == Metric) {
|
||||
_topMargin->setValue(_export->margins.top());
|
||||
_bottomMargin->setValue(_export->margins.bottom());
|
||||
_leftMargin->setValue(_export->margins.left());
|
||||
_rightMargin->setValue(_export->margins.right());
|
||||
} else {
|
||||
_topMargin->setValue(_export->margins.top() * MM2IN);
|
||||
_bottomMargin->setValue(_export->margins.bottom() * MM2IN);
|
||||
_leftMargin->setValue(_export->margins.left() * MM2IN);
|
||||
@ -76,11 +81,6 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
||||
_bottomMargin->setSingleStep(0.1);
|
||||
_leftMargin->setSingleStep(0.1);
|
||||
_rightMargin->setSingleStep(0.1);
|
||||
} else {
|
||||
_topMargin->setValue(_export->margins.top());
|
||||
_bottomMargin->setValue(_export->margins.bottom());
|
||||
_leftMargin->setValue(_export->margins.left());
|
||||
_rightMargin->setValue(_export->margins.right());
|
||||
}
|
||||
|
||||
QGridLayout *marginsLayout = new QGridLayout();
|
||||
|
@ -2,6 +2,32 @@
|
||||
#include "common/coordinates.h"
|
||||
#include "format.h"
|
||||
|
||||
|
||||
static QString deg2DMS(double val)
|
||||
{
|
||||
int deg = val;
|
||||
double r1 = val - deg;
|
||||
|
||||
int min = r1 * 60.0;
|
||||
double r2 = r1 - (min / 60.0);
|
||||
|
||||
double sec = r2 * 3600.0;
|
||||
|
||||
return QString("%1°%2'%3\"").arg(deg).arg(min, 2, 10, QChar('0'))
|
||||
.arg(sec, 4, 'f', 1, QChar('0'));
|
||||
}
|
||||
|
||||
static QString deg2DMM(double val)
|
||||
{
|
||||
int deg = val;
|
||||
double r1 = val - deg;
|
||||
|
||||
double min = r1 * 60.0;
|
||||
|
||||
return QString("%1°%2'").arg(deg).arg(min, 6, 'f', 3, QChar('0'));
|
||||
}
|
||||
|
||||
|
||||
QString Format::timeSpan(qreal time, bool full)
|
||||
{
|
||||
unsigned h, m, s;
|
||||
@ -27,6 +53,13 @@ QString Format::distance(qreal value, Units units)
|
||||
else
|
||||
return QString::number(value * M2MI, 'f', 1) + UNIT_SPACE
|
||||
+ qApp->translate("Format", "mi");
|
||||
} else if (units == Nautical) {
|
||||
if (value < NMIINM)
|
||||
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
|
||||
+ qApp->translate("Format", "ft");
|
||||
else
|
||||
return QString::number(value * M2NMI, 'f', 1) + UNIT_SPACE
|
||||
+ qApp->translate("Format", "nmi");
|
||||
} else {
|
||||
if (value < KMINM)
|
||||
return QString::number(value, 'f', 0) + UNIT_SPACE
|
||||
@ -47,11 +80,22 @@ QString Format::elevation(qreal value, Units units)
|
||||
+ qApp->translate("Format", "ft");
|
||||
}
|
||||
|
||||
QString Format::coordinates(const Coordinates &value)
|
||||
QString Format::coordinates(const Coordinates &value, CoordinatesFormat type)
|
||||
{
|
||||
QChar yH = (value.lat() < 0) ? 'S' : 'N';
|
||||
QChar xH = (value.lon() < 0) ? 'W' : 'E';
|
||||
|
||||
return QString::number(qAbs(value.lat()), 'f', 5) + yH + "," + QChar(0x00A0)
|
||||
+ QString::number(qAbs(value.lon()), 'f', 5) + xH;
|
||||
switch (type) {
|
||||
case DegreesMinutes:
|
||||
return deg2DMM(qAbs(value.lat())) + yH + "," + QChar(0x00A0)
|
||||
+ deg2DMM(qAbs(value.lon())) + xH;
|
||||
break;
|
||||
case DMS:
|
||||
return deg2DMS(qAbs(value.lat())) + yH + "," + QChar(0x00A0)
|
||||
+ deg2DMS(qAbs(value.lon())) + xH;
|
||||
break;
|
||||
default:
|
||||
return QString::number(qAbs(value.lat()), 'f', 5) + yH + ","
|
||||
+ QChar(0x00A0) + QString::number(qAbs(value.lon()), 'f', 5) + xH;
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,18 @@
|
||||
|
||||
class Coordinates;
|
||||
|
||||
enum CoordinatesFormat {
|
||||
DecimalDegrees,
|
||||
DegreesMinutes,
|
||||
DMS
|
||||
};
|
||||
|
||||
namespace Format
|
||||
{
|
||||
QString timeSpan(qreal time, bool full = true);
|
||||
QString distance(qreal value, Units units);
|
||||
QString elevation(qreal value, Units units);
|
||||
QString coordinates(const Coordinates &value);
|
||||
QString coordinates(const Coordinates &value, CoordinatesFormat type);
|
||||
}
|
||||
|
||||
#endif // FORMAT_H
|
||||
|
@ -104,15 +104,7 @@ void GraphView::setYUnits(const QString &units)
|
||||
void GraphView::setXUnits()
|
||||
{
|
||||
if (_graphType == Distance) {
|
||||
if (_units == Metric) {
|
||||
if (bounds().width() < KMINM) {
|
||||
_xUnits = tr("m");
|
||||
_xScale = 1;
|
||||
} else {
|
||||
_xUnits = tr("km");
|
||||
_xScale = M2KM;
|
||||
}
|
||||
} else {
|
||||
if (_units == Imperial) {
|
||||
if (bounds().width() < MIINM) {
|
||||
_xUnits = tr("ft");
|
||||
_xScale = M2FT;
|
||||
@ -120,6 +112,22 @@ void GraphView::setXUnits()
|
||||
_xUnits = tr("mi");
|
||||
_xScale = M2MI;
|
||||
}
|
||||
} else if (_units == Nautical) {
|
||||
if (bounds().width() < NMIINM) {
|
||||
_xUnits = tr("ft");
|
||||
_xScale = M2FT;
|
||||
} else {
|
||||
_xUnits = tr("nmi");
|
||||
_xScale = M2NMI;
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < KMINM) {
|
||||
_xUnits = tr("m");
|
||||
_xScale = 1;
|
||||
} else {
|
||||
_xUnits = tr("km");
|
||||
_xScale = M2KM;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < MININS) {
|
||||
|
226
src/GUI/gui.cpp
226
src/GUI/gui.cpp
@ -40,7 +40,6 @@
|
||||
#include "filebrowser.h"
|
||||
#include "cpuarch.h"
|
||||
#include "graphtab.h"
|
||||
#include "format.h"
|
||||
#include "gui.h"
|
||||
|
||||
|
||||
@ -101,69 +100,31 @@ GUI::~GUI()
|
||||
void GUI::loadMaps()
|
||||
{
|
||||
_ml = new MapList(this);
|
||||
|
||||
QString offline, online;
|
||||
|
||||
if (QFile::exists(USER_MAP_FILE))
|
||||
online = USER_MAP_FILE;
|
||||
else if (QFile::exists(GLOBAL_MAP_FILE))
|
||||
online = GLOBAL_MAP_FILE;
|
||||
|
||||
if (!online.isNull() && !_ml->loadFile(online))
|
||||
qWarning("%s: %s", qPrintable(online), qPrintable(_ml->errorString()));
|
||||
|
||||
QString dir;
|
||||
|
||||
if (QFile::exists(USER_MAP_DIR))
|
||||
offline = USER_MAP_DIR;
|
||||
dir = USER_MAP_DIR;
|
||||
else if (QFile::exists(GLOBAL_MAP_DIR))
|
||||
offline = GLOBAL_MAP_DIR;
|
||||
dir = GLOBAL_MAP_DIR;
|
||||
|
||||
if (!offline.isNull()) {
|
||||
QDir md(offline);
|
||||
QFileInfoList ml = md.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
|
||||
for (int i = 0; i < ml.size(); i++) {
|
||||
QDir dir(ml.at(i).absoluteFilePath());
|
||||
QFileInfoList fl = dir.entryInfoList(MapList::filter(), QDir::Files);
|
||||
|
||||
if (fl.isEmpty())
|
||||
qWarning("%s: no map/atlas file found",
|
||||
qPrintable(ml.at(i).absoluteFilePath()));
|
||||
else if (fl.size() > 1)
|
||||
qWarning("%s: ambiguous directory content",
|
||||
qPrintable(ml.at(i).absoluteFilePath()));
|
||||
else
|
||||
if (!_ml->loadFile(fl.first().absoluteFilePath()))
|
||||
qWarning("%s: %s", qPrintable(fl.first().absoluteFilePath()),
|
||||
qPrintable(_ml->errorString()));
|
||||
}
|
||||
}
|
||||
if (!dir.isNull() && !_ml->loadDir(dir))
|
||||
qWarning("%s", qPrintable(_ml->errorString()));
|
||||
|
||||
_map = new EmptyMap(this);
|
||||
}
|
||||
|
||||
void GUI::loadPOIs()
|
||||
{
|
||||
QFileInfoList list;
|
||||
QDir userDir(USER_POI_DIR);
|
||||
QDir globalDir(GLOBAL_POI_DIR);
|
||||
|
||||
_poi = new POI(this);
|
||||
QString dir;
|
||||
|
||||
if (userDir.exists())
|
||||
list = userDir.entryInfoList(QStringList(), QDir::Files);
|
||||
else
|
||||
list = globalDir.entryInfoList(QStringList(), QDir::Files);
|
||||
if (QFile::exists(USER_POI_DIR))
|
||||
dir = USER_POI_DIR;
|
||||
else if (QFile::exists(GLOBAL_POI_DIR))
|
||||
dir = GLOBAL_POI_DIR;
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
if (!_poi->loadFile(list.at(i).absoluteFilePath())) {
|
||||
qWarning("Error loading POI file: %s: %s\n",
|
||||
qPrintable(list.at(i).fileName()),
|
||||
qPrintable(_poi->errorString()));
|
||||
if (_poi->errorLine())
|
||||
qWarning("Line: %d\n", _poi->errorLine());
|
||||
}
|
||||
}
|
||||
if (!dir.isNull() && !_poi->loadDir(dir))
|
||||
qWarning("%s", qPrintable(_poi->errorString()));
|
||||
}
|
||||
|
||||
void GUI::createBrowser()
|
||||
@ -238,8 +199,8 @@ void GUI::createActions()
|
||||
addAction(_exitAction);
|
||||
|
||||
// Help & About
|
||||
_dataSourcesAction = new QAction(tr("Data sources"), this);
|
||||
connect(_dataSourcesAction, SIGNAL(triggered()), this, SLOT(dataSources()));
|
||||
_pathsAction = new QAction(tr("Paths"), this);
|
||||
connect(_pathsAction, SIGNAL(triggered()), this, SLOT(paths()));
|
||||
_keysAction = new QAction(tr("Keyboard controls"), this);
|
||||
connect(_keysAction, SIGNAL(triggered()), this, SLOT(keys()));
|
||||
_aboutAction = new QAction(QIcon(QPixmap(APP_ICON)),
|
||||
@ -411,6 +372,28 @@ void GUI::createActions()
|
||||
_imperialUnitsAction->setActionGroup(ag);
|
||||
connect(_imperialUnitsAction, SIGNAL(triggered()), this,
|
||||
SLOT(setImperialUnits()));
|
||||
_nauticalUnitsAction = new QAction(tr("Nautical"), this);
|
||||
_nauticalUnitsAction->setCheckable(true);
|
||||
_nauticalUnitsAction->setActionGroup(ag);
|
||||
connect(_nauticalUnitsAction, SIGNAL(triggered()), this,
|
||||
SLOT(setNauticalUnits()));
|
||||
ag = new QActionGroup(this);
|
||||
ag->setExclusive(true);
|
||||
_decimalDegreesAction = new QAction(tr("Decimal degrees (DD)"), this);
|
||||
_decimalDegreesAction->setCheckable(true);
|
||||
_decimalDegreesAction->setActionGroup(ag);
|
||||
connect(_decimalDegreesAction, SIGNAL(triggered()), this,
|
||||
SLOT(setDecimalDegrees()));
|
||||
_degreesMinutesAction = new QAction(tr("Degrees and decimal minutes (DMM)"),
|
||||
this);
|
||||
_degreesMinutesAction->setCheckable(true);
|
||||
_degreesMinutesAction->setActionGroup(ag);
|
||||
connect(_degreesMinutesAction, SIGNAL(triggered()), this,
|
||||
SLOT(setDegreesMinutes()));
|
||||
_DMSAction = new QAction(tr("Degrees, minutes, seconds (DMS)"), this);
|
||||
_DMSAction->setCheckable(true);
|
||||
_DMSAction->setActionGroup(ag);
|
||||
connect(_DMSAction, SIGNAL(triggered()), this, SLOT(setDMS()));
|
||||
_fullscreenAction = new QAction(QIcon(QPixmap(FULLSCREEN_ICON)),
|
||||
tr("Fullscreen mode"), this);
|
||||
_fullscreenAction->setCheckable(true);
|
||||
@ -501,6 +484,11 @@ void GUI::createMenus()
|
||||
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
||||
unitsMenu->addAction(_metricUnitsAction);
|
||||
unitsMenu->addAction(_imperialUnitsAction);
|
||||
unitsMenu->addAction(_nauticalUnitsAction);
|
||||
QMenu *coordinatesMenu = settingsMenu->addMenu(tr("Coordinates format"));
|
||||
coordinatesMenu->addAction(_decimalDegreesAction);
|
||||
coordinatesMenu->addAction(_degreesMinutesAction);
|
||||
coordinatesMenu->addAction(_DMSAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_showToolbarsAction);
|
||||
settingsMenu->addAction(_fullscreenAction);
|
||||
@ -508,7 +496,7 @@ void GUI::createMenus()
|
||||
settingsMenu->addAction(_openOptionsAction);
|
||||
|
||||
QMenu *helpMenu = menuBar()->addMenu(tr("Help"));
|
||||
helpMenu->addAction(_dataSourcesAction);
|
||||
helpMenu->addAction(_pathsAction);
|
||||
helpMenu->addAction(_keysAction);
|
||||
helpMenu->addSeparator();
|
||||
helpMenu->addAction(_aboutAction);
|
||||
@ -644,37 +632,26 @@ void GUI::keys()
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
void GUI::dataSources()
|
||||
void GUI::paths()
|
||||
{
|
||||
QMessageBox msgBox(this);
|
||||
|
||||
msgBox.setWindowTitle(tr("Data sources"));
|
||||
msgBox.setText("<h3>" + tr("Data sources") + "</h3>");
|
||||
msgBox.setWindowTitle(tr("Paths"));
|
||||
msgBox.setText("<h3>" + tr("Paths") + "</h3>");
|
||||
msgBox.setInformativeText(
|
||||
"<h4>" + tr("Online maps") + "</h4><p>"
|
||||
+ tr("Online map URLs are read on program startup from the "
|
||||
"following file:")
|
||||
+ "</p><p><code>" + USER_MAP_FILE + "</code></p><p>"
|
||||
+ tr("The file format is one map entry per line, consisting of the map "
|
||||
"name, tiles URL and an optional maximal zoom level delimited by "
|
||||
"a TAB character. The tile X and Y coordinates are replaced with $x "
|
||||
"and $y in the URL and the zoom level is replaced with $z. An example "
|
||||
"map file could look like:")
|
||||
+ "</p><p><code>Map1 http://tile.server.com/map/$z/$x/$y.png 15"
|
||||
"<br/>Map2 http://mapserver.org/map/$z-$x-$y</code></p>"
|
||||
|
||||
+ "<h4>" + tr("Offline maps") + "</h4><p>"
|
||||
+ tr("Offline maps are loaded on program startup from the following "
|
||||
"directory:")
|
||||
+ "</p><p><code>" + USER_MAP_DIR + "</code></p><p>"
|
||||
+ tr("The expected structure is one map/atlas in a separate subdirectory."
|
||||
" Supported map formats are OziExplorer maps and TrekBuddy maps/atlases"
|
||||
" (tared and non-tared).") + "</p>"
|
||||
|
||||
+ "<h4>" + tr("POIs") + "</h4><p>"
|
||||
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
||||
"the file to the following directory:")
|
||||
+ "</p><p><code>" + USER_POI_DIR + "</code></p>"
|
||||
"<style>td {white-space: pre; padding-right: 1em;}</style>"
|
||||
"<div><table><tr><td>" + tr("Map directory:") + "</td><td><code>"
|
||||
+ QDir::cleanPath(GLOBAL_MAP_DIR) + "</code></td></tr><tr><td>"
|
||||
+ tr("POI directory:") + "</td><td><code>"
|
||||
+ QDir::cleanPath(GLOBAL_POI_DIR) + "</code></td></tr><tr><td>"
|
||||
+ tr("GCS file:") + "</td><td><code>" + QDir::cleanPath(GLOBAL_GCS_FILE)
|
||||
+ "</code></td></tr><tr><td>" + tr("PCS file:") + "</td><td><code>"
|
||||
+ QDir::cleanPath(GLOBAL_PCS_FILE) + "</code></td></tr><tr><td>"
|
||||
+ tr("Ellipsoids file:") + "</td><td><code>"
|
||||
+ QDir::cleanPath(GLOBAL_ELLIPSOID_FILE) + "</code></td></tr>"
|
||||
+ "<tr><td></td><td></td></tr></table></div><div><table><tr><td>"
|
||||
+ tr("User override directory:") + "</td><td><code>"
|
||||
+ QDir::cleanPath(USER_DIR) + "</td></tr></table></div>"
|
||||
);
|
||||
|
||||
msgBox.exec();
|
||||
@ -692,8 +669,6 @@ void GUI::openFile()
|
||||
|
||||
bool GUI::openFile(const QString &fileName)
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
if (fileName.isEmpty() || _files.contains(fileName))
|
||||
return false;
|
||||
|
||||
@ -708,13 +683,14 @@ bool GUI::openFile(const QString &fileName)
|
||||
updateWindowTitle();
|
||||
updateGraphTabs();
|
||||
updateMapView();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if (_files.isEmpty())
|
||||
_fileActionGroup->setEnabled(false);
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool GUI::loadFile(const QString &fileName)
|
||||
@ -1148,30 +1124,38 @@ void GUI::showGraphSliderInfo(bool show)
|
||||
|
||||
void GUI::loadMap()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open map file"),
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open map file"),
|
||||
QString(), MapList::formats());
|
||||
QStringList list = files;
|
||||
|
||||
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
||||
loadMap(*it);
|
||||
}
|
||||
|
||||
bool GUI::loadMap(const QString &fileName)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
int count = _ml->maps().count();
|
||||
if (_ml->loadFile(fileName)) {
|
||||
for (int i = count; i < _ml->maps().count(); i++) {
|
||||
QAction *a = new QAction(_ml->maps().at(i)->name(), this);
|
||||
QAction *a = new QAction(_ml->maps().last()->name(), this);
|
||||
a->setCheckable(true);
|
||||
a->setActionGroup(_mapsActionGroup);
|
||||
_mapsSignalMapper->setMapping(a, i);
|
||||
_mapsSignalMapper->setMapping(a, _ml->maps().size() - 1);
|
||||
connect(a, SIGNAL(triggered()), _mapsSignalMapper, SLOT(map()));
|
||||
_mapActions.append(a);
|
||||
_mapMenu->insertAction(_mapsEnd, a);
|
||||
}
|
||||
_showMapAction->setEnabled(true);
|
||||
_clearMapCacheAction->setEnabled(true);
|
||||
_mapActions.last()->activate(QAction::Trigger);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
QString error = tr("Error loading map:") + "\n\n"
|
||||
+ fileName + "\n\n" + _ml->errorString();
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1335,6 +1319,11 @@ void GUI::setUnits(Units units)
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::setCoordinatesFormat(CoordinatesFormat format)
|
||||
{
|
||||
_mapView->setCoordinatesFormat(format);
|
||||
}
|
||||
|
||||
void GUI::setGraphType(GraphType type)
|
||||
{
|
||||
_sliderPos = 0;
|
||||
@ -1480,10 +1469,14 @@ void GUI::writeSettings()
|
||||
TIME_TYPE_DEFAULT)
|
||||
settings.setValue(TIME_TYPE_SETTING, _movingTimeAction->isChecked()
|
||||
? Moving : Total);
|
||||
if ((_imperialUnitsAction->isChecked() ? Imperial : Metric) !=
|
||||
UNITS_DEFAULT)
|
||||
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
||||
? Imperial : Metric);
|
||||
Units units = _imperialUnitsAction->isChecked() ? Imperial
|
||||
: _nauticalUnitsAction->isChecked() ? Nautical : Metric;
|
||||
if (units != UNITS_DEFAULT)
|
||||
settings.setValue(UNITS_SETTING, units);
|
||||
CoordinatesFormat format = _DMSAction->isChecked() ? DMS
|
||||
: _degreesMinutesAction->isChecked() ? DegreesMinutes : DecimalDegrees;
|
||||
if (format != COORDINATES_DEFAULT)
|
||||
settings.setValue(COORDINATES_SETTING, format);
|
||||
if (_showToolbarsAction->isChecked() != SHOW_TOOLBARS_DEFAULT)
|
||||
settings.setValue(SHOW_TOOLBARS_SETTING,
|
||||
_showToolbarsAction->isChecked());
|
||||
@ -1643,6 +1636,7 @@ void GUI::writeSettings()
|
||||
|
||||
void GUI::readSettings()
|
||||
{
|
||||
int value;
|
||||
QSettings settings(APP_NAME, APP_NAME);
|
||||
|
||||
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
||||
@ -1652,20 +1646,27 @@ void GUI::readSettings()
|
||||
|
||||
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
||||
if (settings.value(TIME_TYPE_SETTING, TIME_TYPE_DEFAULT).toInt()
|
||||
== Moving) {
|
||||
setTimeType(Moving);
|
||||
_movingTimeAction->setChecked(true);
|
||||
} else {
|
||||
setTimeType(Total);
|
||||
_totalTimeAction->setChecked(true);
|
||||
}
|
||||
if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial) {
|
||||
setUnits(Imperial);
|
||||
_imperialUnitsAction->setChecked(true);
|
||||
} else {
|
||||
setUnits(Metric);
|
||||
_metricUnitsAction->setChecked(true);
|
||||
}
|
||||
== Moving)
|
||||
_movingTimeAction->activate(QAction::Trigger);
|
||||
else
|
||||
_totalTimeAction->activate(QAction::Trigger);
|
||||
|
||||
value = settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt();
|
||||
if (value == Imperial)
|
||||
_imperialUnitsAction->activate(QAction::Trigger);
|
||||
else if (value == Nautical)
|
||||
_nauticalUnitsAction->activate(QAction::Trigger);
|
||||
else
|
||||
_metricUnitsAction->activate(QAction::Trigger);
|
||||
|
||||
value = settings.value(COORDINATES_SETTING, COORDINATES_DEFAULT).toInt();
|
||||
if (value == DMS)
|
||||
_DMSAction->activate(QAction::Trigger);
|
||||
else if (value == DegreesMinutes)
|
||||
_degreesMinutesAction->activate(QAction::Trigger);
|
||||
else
|
||||
_decimalDegreesAction->activate(QAction::Trigger);
|
||||
|
||||
if (!settings.value(SHOW_TOOLBARS_SETTING, SHOW_TOOLBARS_DEFAULT).toBool())
|
||||
showToolbars(false);
|
||||
else
|
||||
@ -1909,7 +1910,8 @@ int GUI::mapIndex(const QString &name)
|
||||
|
||||
Units GUI::units() const
|
||||
{
|
||||
return _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||
return _imperialUnitsAction->isChecked() ? Imperial
|
||||
: _nauticalUnitsAction->isChecked() ? Nautical : Metric;
|
||||
}
|
||||
|
||||
qreal GUI::distance() const
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "data/poi.h"
|
||||
#include "units.h"
|
||||
#include "timetype.h"
|
||||
#include "format.h"
|
||||
#include "exportdialog.h"
|
||||
#include "optionsdialog.h"
|
||||
|
||||
@ -40,7 +41,7 @@ public:
|
||||
private slots:
|
||||
void about();
|
||||
void keys();
|
||||
void dataSources();
|
||||
void paths();
|
||||
void printFile();
|
||||
void exportFile();
|
||||
void openFile();
|
||||
@ -73,8 +74,12 @@ private slots:
|
||||
void setMovingTime() {setTimeType(Moving);}
|
||||
void setMetricUnits() {setUnits(Metric);}
|
||||
void setImperialUnits() {setUnits(Imperial);}
|
||||
void setNauticalUnits() {setUnits(Nautical);}
|
||||
void setDistanceGraph() {setGraphType(Distance);}
|
||||
void setTimeGraph() {setGraphType(Time);}
|
||||
void setDecimalDegrees() {setCoordinatesFormat(DecimalDegrees);}
|
||||
void setDegreesMinutes() {setCoordinatesFormat(DegreesMinutes);}
|
||||
void setDMS() {setCoordinatesFormat(DMS);}
|
||||
|
||||
void sliderPositionChanged(qreal pos);
|
||||
|
||||
@ -99,6 +104,7 @@ private:
|
||||
|
||||
bool openPOIFile(const QString &fileName);
|
||||
bool loadFile(const QString &fileName);
|
||||
bool loadMap(const QString &fileName);
|
||||
void exportFile(const QString &fileName);
|
||||
void updateStatusBarInfo();
|
||||
void updateWindowTitle();
|
||||
@ -110,6 +116,7 @@ private:
|
||||
Units units() const;
|
||||
void setTimeType(TimeType type);
|
||||
void setUnits(Units units);
|
||||
void setCoordinatesFormat(CoordinatesFormat format);
|
||||
void setGraphType(GraphType type);
|
||||
|
||||
qreal distance() const;
|
||||
@ -135,7 +142,7 @@ private:
|
||||
QActionGroup *_mapsActionGroup;
|
||||
QAction *_exitAction;
|
||||
QAction *_keysAction;
|
||||
QAction *_dataSourcesAction;
|
||||
QAction *_pathsAction;
|
||||
QAction *_aboutAction;
|
||||
QAction *_aboutQtAction;
|
||||
QAction *_printFileAction;
|
||||
@ -164,6 +171,10 @@ private:
|
||||
QAction *_firstAction;
|
||||
QAction *_metricUnitsAction;
|
||||
QAction *_imperialUnitsAction;
|
||||
QAction *_nauticalUnitsAction;
|
||||
QAction *_decimalDegreesAction;
|
||||
QAction *_degreesMinutesAction;
|
||||
QAction *_DMSAction;
|
||||
QAction *_totalTimeAction;
|
||||
QAction *_movingTimeAction;
|
||||
QAction *_nextMapAction;
|
||||
|
@ -49,6 +49,7 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
||||
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||
|
||||
_units = Metric;
|
||||
_coordinatesFormat = DecimalDegrees;
|
||||
_opacity = 1.0;
|
||||
_backgroundColor = Qt::white;
|
||||
_markerColor = Qt::red;
|
||||
@ -137,6 +138,7 @@ PathItem *MapView::addRoute(const Route &route)
|
||||
ri->setWidth(_routeWidth);
|
||||
ri->setStyle(_routeStyle);
|
||||
ri->setUnits(_units);
|
||||
ri->setCoordinatesFormat(_coordinatesFormat);
|
||||
ri->setVisible(_showRoutes);
|
||||
ri->showWaypoints(_showRouteWaypoints);
|
||||
ri->showWaypointLabels(_showWaypointLabels);
|
||||
@ -162,7 +164,7 @@ void MapView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
wi->setSize(_waypointSize);
|
||||
wi->setColor(_waypointColor);
|
||||
wi->showLabel(_showWaypointLabels);
|
||||
wi->setUnits(_units);
|
||||
wi->setToolTipFormat(_units, _coordinatesFormat);
|
||||
wi->setVisible(_showWaypoints);
|
||||
wi->setDigitalZoom(_digitalZoom);
|
||||
_scene->addItem(wi);
|
||||
@ -348,28 +350,49 @@ void MapView::addPOI(const QList<Waypoint> &waypoints)
|
||||
pi->showLabel(_showPOILabels);
|
||||
pi->setVisible(_showPOI);
|
||||
pi->setDigitalZoom(_digitalZoom);
|
||||
pi->setToolTipFormat(_units, _coordinatesFormat);
|
||||
_scene->addItem(pi);
|
||||
|
||||
_pois.insert(SearchPointer<Waypoint>(&(pi->waypoint())), pi);
|
||||
}
|
||||
}
|
||||
|
||||
void MapView::setUnits(enum Units units)
|
||||
void MapView::setUnits(Units units)
|
||||
{
|
||||
if (_units == units)
|
||||
return;
|
||||
|
||||
_units = units;
|
||||
|
||||
_mapScale->setUnits(units);
|
||||
_mapScale->setUnits(_units);
|
||||
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks[i]->setUnits(units);
|
||||
_tracks[i]->setUnits(_units);
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes[i]->setUnits(units);
|
||||
_routes[i]->setUnits(_units);
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setUnits(units);
|
||||
_waypoints.at(i)->setToolTipFormat(_units, _coordinatesFormat);
|
||||
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setUnits(units);
|
||||
it.value()->setToolTipFormat(_units, _coordinatesFormat);
|
||||
}
|
||||
|
||||
void MapView::setCoordinatesFormat(CoordinatesFormat format)
|
||||
{
|
||||
if (_coordinatesFormat == format)
|
||||
return;
|
||||
|
||||
_coordinatesFormat = format;
|
||||
|
||||
for (int i = 0; i < _waypoints.count(); i++)
|
||||
_waypoints.at(i)->setToolTipFormat(_units, _coordinatesFormat);
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes[i]->setCoordinatesFormat(_coordinatesFormat);
|
||||
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setToolTipFormat(_units, _coordinatesFormat);
|
||||
}
|
||||
|
||||
void MapView::clearMapCache()
|
||||
@ -566,6 +589,9 @@ void MapView::clear()
|
||||
_wr = RectC();
|
||||
|
||||
digitalZoom(0);
|
||||
|
||||
// If not reset, causes huge redraw areas (and system memory exhaustion)
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void MapView::showTracks(bool show)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "data/waypoint.h"
|
||||
#include "searchpointer.h"
|
||||
#include "units.h"
|
||||
#include "format.h"
|
||||
#include "palette.h"
|
||||
|
||||
class Data;
|
||||
@ -34,12 +35,13 @@ public:
|
||||
void setPalette(const Palette &palette);
|
||||
void setPOI(POI *poi);
|
||||
void setMap(Map *map);
|
||||
void setUnits(enum Units units);
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target, qreal scale, bool hires);
|
||||
|
||||
void clear();
|
||||
|
||||
void setUnits(Units units);
|
||||
void setMarkerColor(const QColor &color);
|
||||
void setTrackWidth(int width);
|
||||
void setRouteWidth(int width);
|
||||
void setTrackStyle(Qt::PenStyle style);
|
||||
@ -52,7 +54,6 @@ public:
|
||||
void setBackgroundColor(const QColor &color);
|
||||
void useOpenGL(bool use);
|
||||
void useAntiAliasing(bool use);
|
||||
void setMarkerColor(const QColor &color);
|
||||
|
||||
public slots:
|
||||
void showMap(bool show);
|
||||
@ -65,6 +66,7 @@ public slots:
|
||||
void showWaypoints(bool show);
|
||||
void showRouteWaypoints(bool show);
|
||||
void clearMapCache();
|
||||
void setCoordinatesFormat(CoordinatesFormat format);
|
||||
|
||||
private slots:
|
||||
void updatePOI();
|
||||
@ -108,6 +110,7 @@ private:
|
||||
POI *_poi;
|
||||
Palette _palette;
|
||||
Units _units;
|
||||
CoordinatesFormat _coordinatesFormat;
|
||||
|
||||
qreal _opacity;
|
||||
QColor _backgroundColor;
|
||||
|
@ -1,9 +0,0 @@
|
||||
#include "margins.h"
|
||||
|
||||
|
||||
QDebug operator<<(QDebug dbg, const MarginsF &margins)
|
||||
{
|
||||
dbg.nospace() << "MarginsF(" << margins.left() << ", " << margins.top()
|
||||
<< ", " << margins.right() << margins.bottom() << ")";
|
||||
return dbg.maybeSpace();
|
||||
}
|
@ -25,6 +25,11 @@ private:
|
||||
qreal _left, _top, _right, _bottom;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug dbg, const MarginsF &margins);
|
||||
inline QDebug operator<<(QDebug dbg, const MarginsF &margins)
|
||||
{
|
||||
dbg.nospace() << "MarginsF(" << margins.left() << ", " << margins.top()
|
||||
<< ", " << margins.right() << margins.bottom() << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
#endif // MARGINS_H
|
||||
|
@ -291,6 +291,9 @@ QWidget *OptionsDialog::createDataPage()
|
||||
if (_options->units == Imperial) {
|
||||
_pauseSpeed->setValue(_options->pauseSpeed * MS2MIH);
|
||||
_pauseSpeed->setSuffix(UNIT_SPACE + tr("mi/h"));
|
||||
} else if (_options->units == Nautical) {
|
||||
_pauseSpeed->setValue(_options->pauseSpeed * MS2KN);
|
||||
_pauseSpeed->setSuffix(UNIT_SPACE + tr("kn"));
|
||||
} else {
|
||||
_pauseSpeed->setValue(_options->pauseSpeed * MS2KMH);
|
||||
_pauseSpeed->setSuffix(UNIT_SPACE + tr("km/h"));
|
||||
@ -323,6 +326,9 @@ QWidget *OptionsDialog::createPOIPage()
|
||||
if (_options->units == Imperial) {
|
||||
_poiRadius->setValue(_options->poiRadius / MIINM);
|
||||
_poiRadius->setSuffix(UNIT_SPACE + tr("mi"));
|
||||
} else if (_options->units == Nautical) {
|
||||
_poiRadius->setValue(_options->poiRadius / NMIINM);
|
||||
_poiRadius->setSuffix(UNIT_SPACE + tr("nmi"));
|
||||
} else {
|
||||
_poiRadius->setValue(_options->poiRadius / KMINM);
|
||||
_poiRadius->setSuffix(UNIT_SPACE + tr("km"));
|
||||
@ -525,13 +531,15 @@ void OptionsDialog::accept()
|
||||
_options->powerFilter = _powerFilter->value();
|
||||
_options->outlierEliminate = _outlierEliminate->isChecked();
|
||||
qreal pauseSpeed = (_options->units == Imperial)
|
||||
? _pauseSpeed->value() / MS2MIH : _pauseSpeed->value() / MS2KMH;
|
||||
? _pauseSpeed->value() / MS2MIH : (_options->units == Nautical)
|
||||
? _pauseSpeed->value() / MS2KN : _pauseSpeed->value() / MS2KMH;
|
||||
if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01)
|
||||
_options->pauseSpeed = pauseSpeed;
|
||||
_options->pauseInterval = _pauseInterval->value();
|
||||
|
||||
qreal poiRadius = (_options->units == Imperial)
|
||||
? _poiRadius->value() * MIINM : _poiRadius->value() * KMINM;
|
||||
? _poiRadius->value() * MIINM : (_options->units == Nautical)
|
||||
? _poiRadius->value() * NMIINM : _poiRadius->value() * KMINM;
|
||||
if (qAbs(poiRadius - _options->poiRadius) > 0.01)
|
||||
_options->poiRadius = poiRadius;
|
||||
|
||||
|
@ -30,6 +30,8 @@ RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
|
||||
|
||||
_name = route.name();
|
||||
_desc = route.description();
|
||||
_units = Metric;
|
||||
_coordinatesFormat = DecimalDegrees;
|
||||
|
||||
setToolTip(toolTip(Metric));
|
||||
}
|
||||
@ -47,9 +49,38 @@ void RouteItem::setMap(Map *map)
|
||||
PathItem::setMap(map);
|
||||
}
|
||||
|
||||
void RouteItem::setUnits(enum Units units)
|
||||
void RouteItem::setUnits(Units units)
|
||||
{
|
||||
setToolTip(toolTip(units));
|
||||
if (_units == units)
|
||||
return;
|
||||
|
||||
_units = units;
|
||||
|
||||
setToolTip(toolTip(_units));
|
||||
|
||||
QList<QGraphicsItem *> childs = childItems();
|
||||
for (int i = 0; i < childs.count(); i++) {
|
||||
if (childs.at(i) != _marker) {
|
||||
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
||||
wi->setToolTipFormat(_units, _coordinatesFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RouteItem::setCoordinatesFormat(CoordinatesFormat format)
|
||||
{
|
||||
if (_coordinatesFormat == format)
|
||||
return;
|
||||
|
||||
_coordinatesFormat = format;
|
||||
|
||||
QList<QGraphicsItem *> childs = childItems();
|
||||
for (int i = 0; i < childs.count(); i++) {
|
||||
if (childs.at(i) != _marker) {
|
||||
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
||||
wi->setToolTipFormat(_units, _coordinatesFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RouteItem::showWaypoints(bool show)
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "data/route.h"
|
||||
#include "pathitem.h"
|
||||
#include "units.h"
|
||||
#include "format.h"
|
||||
|
||||
class Map;
|
||||
|
||||
@ -17,6 +18,7 @@ public:
|
||||
void setMap(Map *map);
|
||||
|
||||
void setUnits(Units units);
|
||||
void setCoordinatesFormat(CoordinatesFormat format);
|
||||
void showWaypoints(bool show);
|
||||
void showWaypointLabels(bool show);
|
||||
|
||||
@ -25,6 +27,8 @@ private:
|
||||
|
||||
QString _name;
|
||||
QString _desc;
|
||||
Units _units;
|
||||
CoordinatesFormat _coordinatesFormat;
|
||||
};
|
||||
|
||||
#endif // ROUTEITEM_H
|
||||
|
@ -82,6 +82,9 @@ 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");
|
||||
@ -94,8 +97,18 @@ void ScaleItem::computeScale()
|
||||
if (_units == Imperial) {
|
||||
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, 1);
|
||||
if (_length >= MIINFT) {
|
||||
_length = niceNum((res * M2FT * FT2MI * SCALE_WIDTH) / SEGMENTS, 1);
|
||||
_width = (_length / (res * M2FT * FT2MI));
|
||||
_length = niceNum((res * M2MI * SCALE_WIDTH) / SEGMENTS, 1);
|
||||
_width = (_length / (res * M2MI));
|
||||
_scale = true;
|
||||
} else {
|
||||
_width = (_length / (res * M2FT));
|
||||
_scale = false;
|
||||
}
|
||||
} else if (_units == Nautical) {
|
||||
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, 1);
|
||||
if (_length >= NMIINFT) {
|
||||
_length = niceNum((res * M2NMI * SCALE_WIDTH) / SEGMENTS, 1);
|
||||
_width = (_length / (res * M2NMI));
|
||||
_scale = true;
|
||||
} else {
|
||||
_width = (_length / (res * M2FT));
|
||||
|
@ -15,6 +15,8 @@
|
||||
#define TIME_TYPE_DEFAULT Total
|
||||
#define UNITS_SETTING "units"
|
||||
#define UNITS_DEFAULT (IMPERIAL_UNITS() ? Imperial : Metric)
|
||||
#define COORDINATES_SETTING "coordinates"
|
||||
#define COORDINATES_DEFAULT DecimalDegrees
|
||||
#define SHOW_TOOLBARS_SETTING "toolbar"
|
||||
#define SHOW_TOOLBARS_DEFAULT true
|
||||
|
||||
|
@ -79,12 +79,15 @@ void SpeedGraph::clear()
|
||||
|
||||
void SpeedGraph::setYUnits(Units units)
|
||||
{
|
||||
if (units == Metric) {
|
||||
GraphView::setYUnits(tr("km/h"));
|
||||
setYScale(MS2KMH);
|
||||
} else {
|
||||
if (units == Nautical) {
|
||||
GraphView::setYUnits(tr("kn"));
|
||||
setYScale(MS2KN);
|
||||
} else if (units == Imperial) {
|
||||
GraphView::setYUnits(tr("mi/h"));
|
||||
setYScale(MS2MIH);
|
||||
} else {
|
||||
GraphView::setYUnits(tr("km/h"));
|
||||
setYScale(MS2KMH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,10 @@ SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type,
|
||||
QString SpeedGraphItem::toolTip() const
|
||||
{
|
||||
ToolTip tt;
|
||||
qreal scale = (_units == Metric) ? MS2KMH : MS2MIH;
|
||||
QString su = (_units == Metric) ? tr("km/h") : tr("mi/h");
|
||||
qreal scale = (_units == Imperial) ? MS2MIH : (_units == Nautical)
|
||||
? MS2KN : MS2KMH;
|
||||
QString su = (_units == Imperial) ? tr("mi/h") : (_units == Nautical)
|
||||
? tr("kn") : tr("km/h");
|
||||
|
||||
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 1)
|
||||
+ UNIT_SPACE + su);
|
||||
|
@ -3,14 +3,17 @@
|
||||
|
||||
enum Units {
|
||||
Metric,
|
||||
Imperial
|
||||
Imperial,
|
||||
Nautical
|
||||
};
|
||||
|
||||
#define M2KM 0.001000000000 // m -> km
|
||||
#define M2MI 0.000621371192 // m -> mi
|
||||
#define M2NMI 0.000539956803 // m -> nmi
|
||||
#define M2FT 3.280839900000 // m -> ft
|
||||
#define MS2KMH 3.600000000000 // m/s -> km/h
|
||||
#define MS2MIH 2.236936290000 // m/s -> mi/h
|
||||
#define MS2KN 1.943844490000 // m/s -> kn
|
||||
#define FT2MI 0.000189393939 // ft -> mi
|
||||
#define MM2IN 0.039370100000 // mm -> in
|
||||
#define H2S 0.000277777778 // h -> s
|
||||
@ -18,7 +21,9 @@ enum Units {
|
||||
|
||||
#define KMINM 1000.0 // 1 km in m
|
||||
#define MIINFT 5280.0 // 1 mi in ft
|
||||
#define NMIINFT 6076.11549 // 1 nm in ft
|
||||
#define MIINM 1609.344 // 1 mi in m
|
||||
#define NMIINM 1852.0 // 1 nmi in m
|
||||
#define MININS 60.0 // 1 min in s
|
||||
#define HINS 3600.0 // 1 hins
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include "config.h"
|
||||
#include "format.h"
|
||||
#include "tooltip.h"
|
||||
#include "waypointitem.h"
|
||||
|
||||
@ -11,14 +10,14 @@
|
||||
#define FS(size) \
|
||||
((int)((qreal)size * 1.41))
|
||||
|
||||
QString WaypointItem::toolTip(Units units)
|
||||
QString WaypointItem::toolTip(Units units, CoordinatesFormat format)
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
if (!_waypoint.name().isEmpty())
|
||||
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
|
||||
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
||||
Format::coordinates(_waypoint.coordinates()));
|
||||
Format::coordinates(_waypoint.coordinates(), format));
|
||||
if (!std::isnan(_waypoint.elevation()))
|
||||
tt.insert(qApp->translate("WaypointItem", "Elevation"),
|
||||
Format::elevation(_waypoint.elevation(), units));
|
||||
@ -44,7 +43,7 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
|
||||
updateShape();
|
||||
|
||||
setPos(map->ll2xy(waypoint.coordinates()));
|
||||
setToolTip(toolTip(Metric));
|
||||
setToolTip(toolTip(Metric, DecimalDegrees));
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
@ -108,6 +107,9 @@ void WaypointItem::paint(QPainter *painter,
|
||||
|
||||
void WaypointItem::setSize(int size)
|
||||
{
|
||||
if (_size == size)
|
||||
return;
|
||||
|
||||
prepareGeometryChange();
|
||||
_size = size;
|
||||
updateShape();
|
||||
@ -115,17 +117,23 @@ void WaypointItem::setSize(int size)
|
||||
|
||||
void WaypointItem::setColor(const QColor &color)
|
||||
{
|
||||
if (_color == color)
|
||||
return;
|
||||
|
||||
_color = color;
|
||||
update();
|
||||
}
|
||||
|
||||
void WaypointItem::setUnits(enum Units units)
|
||||
void WaypointItem::setToolTipFormat(Units units, CoordinatesFormat format)
|
||||
{
|
||||
setToolTip(toolTip(units));
|
||||
setToolTip(toolTip(units, format));
|
||||
}
|
||||
|
||||
void WaypointItem::showLabel(bool show)
|
||||
{
|
||||
if (_showLabel == show)
|
||||
return;
|
||||
|
||||
prepareGeometryChange();
|
||||
_showLabel = show;
|
||||
updateShape();
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "data/waypoint.h"
|
||||
#include "map/map.h"
|
||||
#include "units.h"
|
||||
#include "format.h"
|
||||
|
||||
class WaypointItem : public QGraphicsItem
|
||||
{
|
||||
@ -15,7 +16,7 @@ public:
|
||||
const Waypoint &waypoint() const {return _waypoint;}
|
||||
|
||||
void setMap(Map *map) {setPos(map->ll2xy(_waypoint.coordinates()));}
|
||||
void setUnits(Units units);
|
||||
void setToolTipFormat(Units units, CoordinatesFormat format);
|
||||
void setSize(int size);
|
||||
void setColor(const QColor &color);
|
||||
void showLabel(bool show);
|
||||
@ -31,7 +32,7 @@ private:
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
void updateShape();
|
||||
QString toolTip(Units units);
|
||||
QString toolTip(Units units, CoordinatesFormat format);
|
||||
|
||||
QPainterPath _shape;
|
||||
Waypoint _waypoint;
|
||||
|
15
src/config.h
15
src/config.h
@ -12,9 +12,9 @@
|
||||
#define FONT_FAMILY "Arial"
|
||||
#define FONT_SIZE 12 // px
|
||||
|
||||
#define ELLIPSOID_FILE QString("ellipsoids.csv")
|
||||
#define DATUM_FILE QString("datums.csv")
|
||||
#define MAP_FILE QString("maps.txt")
|
||||
#define ELLIPSOID_FILE QString("csv/ellipsoids.csv")
|
||||
#define GCS_FILE QString("csv/gcs.csv")
|
||||
#define PCS_FILE QString("csv/pcs.csv")
|
||||
#define MAP_DIR QString("maps")
|
||||
#define POI_DIR QString("POI")
|
||||
|
||||
@ -31,15 +31,16 @@
|
||||
#endif
|
||||
|
||||
#define USER_ELLIPSOID_FILE USER_DIR + QString("/") + ELLIPSOID_FILE
|
||||
#define USER_DATUM_FILE USER_DIR + QString("/") + DATUM_FILE
|
||||
#define USER_GCS_FILE USER_DIR + QString("/") + GCS_FILE
|
||||
#define USER_PCS_FILE USER_DIR + QString("/") + PCS_FILE
|
||||
#define USER_MAP_DIR USER_DIR + QString("/") + MAP_DIR
|
||||
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
|
||||
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
|
||||
#define GLOBAL_ELLIPSOID_FILE GLOBAL_DIR + QString("/") + ELLIPSOID_FILE
|
||||
#define GLOBAL_DATUM_FILE GLOBAL_DIR + QString("/") + DATUM_FILE
|
||||
#define GLOBAL_GCS_FILE GLOBAL_DIR + QString("/") + GCS_FILE
|
||||
#define GLOBAL_PCS_FILE GLOBAL_DIR + QString("/") + PCS_FILE
|
||||
#define GLOBAL_MAP_DIR GLOBAL_DIR + QString("/") + MAP_DIR
|
||||
#define GLOBAL_MAP_FILE GLOBAL_DIR + QString("/") + MAP_FILE
|
||||
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
|
||||
#define TILES_DIR USER_DIR + QString("/tiles")
|
||||
#define TRANSLATIONS_DIR GLOBAL_DIR + QString("/translations")
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
|
@ -7,7 +7,6 @@ class CSVParser : public Parser
|
||||
{
|
||||
public:
|
||||
CSVParser() : _errorLine(0) {}
|
||||
~CSVParser() {}
|
||||
|
||||
bool parse(QFile *file, QList<TrackData> &track, QList<RouteData> &routes,
|
||||
QList<Waypoint> &waypoints);
|
||||
|
@ -99,11 +99,12 @@ bool Data::loadFile(const QString &fileName)
|
||||
|
||||
QString Data::formats()
|
||||
{
|
||||
return tr("Supported files (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)")
|
||||
+ ";;" + tr("CSV files (*.csv)") + ";;" + tr("FIT files (*.fit)") + ";;"
|
||||
+ tr("GPX files (*.gpx)") + ";;" + tr("IGC files (*.igc)") + ";;"
|
||||
+ tr("KML files (*.kml)") + ";;" + tr("NMEA files (*.nmea)") + ";;"
|
||||
+ tr("TCX files (*.tcx)") + ";;" + tr("All files (*)");
|
||||
return
|
||||
tr("Supported files") + " (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx);;"
|
||||
+ tr("CSV files") + " (*.csv);;" + tr("FIT files") + " (*.fit);;"
|
||||
+ tr("GPX files") + " (*.gpx);;" + tr("IGC files") + " (*.igc);;"
|
||||
+ tr("KML files") + " (*.kml);;" + tr("NMEA files") + " (*.nmea);;"
|
||||
+ tr("TCX files") + " (*.tcx);;" + tr("All files") + "(*)";
|
||||
}
|
||||
|
||||
QStringList Data::filter()
|
||||
|
@ -7,7 +7,6 @@ class FITParser : public Parser
|
||||
{
|
||||
public:
|
||||
FITParser();
|
||||
~FITParser() {}
|
||||
|
||||
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||
QList<Waypoint> &waypoints);
|
||||
|
@ -8,8 +8,6 @@
|
||||
class GPXParser : public Parser
|
||||
{
|
||||
public:
|
||||
~GPXParser() {}
|
||||
|
||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
||||
QList<RouteData> &routes, QList<Waypoint> &waypoints);
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <cstring>
|
||||
#include "str2int.h"
|
||||
#include "common/str2int.h"
|
||||
#include "igcparser.h"
|
||||
|
||||
|
||||
@ -47,22 +47,22 @@ static bool readLon(const char *data, qreal &lon)
|
||||
|
||||
static bool readAltitude(const char *data, qreal &ele)
|
||||
{
|
||||
int p;
|
||||
int ga;
|
||||
|
||||
if (!(data[0] == 'A' || data[0] == 'V'))
|
||||
return false;
|
||||
|
||||
if (data[1] == '-')
|
||||
p = str2int(data + 2, 4);
|
||||
else
|
||||
p = str2int(data + 1, 5);
|
||||
|
||||
int g = str2int(data + 6, 5);
|
||||
if (p < 0 || g < 0)
|
||||
if (data[6] == '-') {
|
||||
if ((ga = str2int(data + 7, 4)) < 0)
|
||||
return false;
|
||||
ga = -ga;
|
||||
} else {
|
||||
if ((ga = str2int(data + 6, 5)) < 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data[0] == 'A')
|
||||
ele = (qreal)g;
|
||||
ele = (qreal)ga;
|
||||
else
|
||||
ele = NAN;
|
||||
|
||||
@ -87,7 +87,7 @@ static bool readTimestamp(const char *data, QTime &time)
|
||||
|
||||
static bool readARecord(const char *line, qint64 len)
|
||||
{
|
||||
if (len < 9 || line[0] != 'A')
|
||||
if (len < 7 || line[0] != 'A')
|
||||
return false;
|
||||
|
||||
for (int i = 1; i < 7; i++)
|
||||
|
@ -10,7 +10,6 @@ class IGCParser : public Parser
|
||||
{
|
||||
public:
|
||||
IGCParser() : _errorLine(0) {}
|
||||
~IGCParser() {}
|
||||
|
||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
||||
QList<RouteData> &routes, QList<Waypoint> &waypoints);
|
||||
|
@ -8,8 +8,6 @@
|
||||
class KMLParser : public Parser
|
||||
{
|
||||
public:
|
||||
~KMLParser() {}
|
||||
|
||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
||||
QList<RouteData> &routes, QList<Waypoint> &waypoints);
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <cstring>
|
||||
#include "str2int.h"
|
||||
#include "common/str2int.h"
|
||||
#include "nmeaparser.h"
|
||||
|
||||
|
||||
|
@ -9,7 +9,6 @@ class NMEAParser : public Parser
|
||||
{
|
||||
public:
|
||||
NMEAParser() : _errorLine(0), _GGA(false) {}
|
||||
~NMEAParser() {}
|
||||
|
||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
||||
QList<RouteData> &routes, QList<Waypoint> &waypoints);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include "data.h"
|
||||
#include "poi.h"
|
||||
|
||||
@ -9,20 +10,25 @@ POI::POI(QObject *parent) : QObject(parent)
|
||||
_radius = 1000;
|
||||
}
|
||||
|
||||
bool POI::loadFile(const QString &fileName)
|
||||
bool POI::loadFile(const QString &path, bool dir)
|
||||
{
|
||||
Data data;
|
||||
FileIndex index;
|
||||
|
||||
_errorString.clear();
|
||||
_errorLine = 0;
|
||||
|
||||
index.enabled = true;
|
||||
index.start = _data.size();
|
||||
|
||||
if (!data.loadFile(fileName)) {
|
||||
if (!data.loadFile(path)) {
|
||||
if (dir) {
|
||||
if (data.errorLine())
|
||||
_errorString += QString("%1:%2: %3\n").arg(path)
|
||||
.arg(data.errorLine()).arg(data.errorString());
|
||||
else
|
||||
_errorString += path + ": " + data.errorString() + "\n";
|
||||
} else {
|
||||
_errorString = data.errorString();
|
||||
_errorLine = data.errorLine();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -38,7 +44,7 @@ bool POI::loadFile(const QString &fileName)
|
||||
_tree.Insert(c, c, i);
|
||||
}
|
||||
|
||||
_files.append(fileName);
|
||||
_files.append(path);
|
||||
_indexes.append(index);
|
||||
|
||||
emit pointsChanged();
|
||||
@ -46,6 +52,39 @@ bool POI::loadFile(const QString &fileName)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool POI::loadFile(const QString &path)
|
||||
{
|
||||
_errorString.clear();
|
||||
_errorLine = 0;
|
||||
|
||||
return loadFile(path, false);
|
||||
}
|
||||
|
||||
bool POI::loadDir(const QString &path)
|
||||
{
|
||||
QDir md(path);
|
||||
md.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
QFileInfoList fl = md.entryInfoList();
|
||||
bool ret = true;
|
||||
|
||||
_errorString.clear();
|
||||
_errorLine = 0;
|
||||
|
||||
for (int i = 0; i < fl.size(); i++) {
|
||||
const QFileInfo &fi = fl.at(i);
|
||||
|
||||
if (fi.isDir()) {
|
||||
if (!loadDir(fi.absoluteFilePath()))
|
||||
ret = false;
|
||||
} else {
|
||||
if (!loadFile(fi.absoluteFilePath(), true))
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool cb(size_t data, void* context)
|
||||
{
|
||||
QSet<int> *set = (QSet<int>*) context;
|
||||
|
@ -18,7 +18,8 @@ class POI : public QObject
|
||||
public:
|
||||
POI(QObject *parent = 0);
|
||||
|
||||
bool loadFile(const QString &fileName);
|
||||
bool loadFile(const QString &path);
|
||||
bool loadDir(const QString &path);
|
||||
const QString &errorString() const {return _errorString;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
@ -43,6 +44,8 @@ private:
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
bool loadFile(const QString &path, bool dir);
|
||||
|
||||
POITree _tree;
|
||||
QVector<Waypoint> _data;
|
||||
QStringList _files;
|
||||
|
@ -8,8 +8,6 @@
|
||||
class TCXParser : public Parser
|
||||
{
|
||||
public:
|
||||
~TCXParser() {}
|
||||
|
||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
||||
QList<RouteData> &routes, QList<Waypoint> &waypoints);
|
||||
QString errorString() const {return _reader.errorString();}
|
||||
|
@ -56,7 +56,7 @@ Defense.
|
||||
((clat) / sqrt(one_minus_sqr_es_sin))
|
||||
|
||||
|
||||
AlbersEqual::AlbersEqual(const Ellipsoid &ellipsoid, double standardParallel1,
|
||||
AlbersEqual::AlbersEqual(const Ellipsoid *ellipsoid, double standardParallel1,
|
||||
double standardParallel2, double latitudeOrigin, double longitudeOrigin,
|
||||
double falseEasting, double falseNorthing)
|
||||
{
|
||||
@ -78,7 +78,7 @@ AlbersEqual::AlbersEqual(const Ellipsoid &ellipsoid, double standardParallel1,
|
||||
sp1 = deg2rad(standardParallel1);
|
||||
sp2 = deg2rad(standardParallel2);
|
||||
|
||||
_es2 = 2 * _e.flattening() - _e.flattening() * _e.flattening();
|
||||
_es2 = 2 * _e->flattening() - _e->flattening() * _e->flattening();
|
||||
_es = sqrt(_es2);
|
||||
_one_minus_es2 = 1 - _es2;
|
||||
_two_es = 2 * _es;
|
||||
@ -108,7 +108,7 @@ AlbersEqual::AlbersEqual(const Ellipsoid &ellipsoid, double standardParallel1,
|
||||
_n = sin_lat1;
|
||||
|
||||
_C = sqr_m1 + _n * q1;
|
||||
_a_over_n = _e.radius() / _n;
|
||||
_a_over_n = _e->radius() / _n;
|
||||
nq0 = _n * q0;
|
||||
_rho0 = (_C < nq0) ? 0 : _a_over_n * sqrt(_C - nq0);
|
||||
}
|
||||
@ -171,7 +171,7 @@ Coordinates AlbersEqual::xy2ll(const QPointF &p) const
|
||||
if (rho != 0.0)
|
||||
theta = atan2(dx, rho0_minus_dy);
|
||||
rho_n = rho * _n;
|
||||
q = (_C - (rho_n * rho_n) / (_e.radius() * _e.radius())) / _n;
|
||||
q = (_C - (rho_n * rho_n) / (_e->radius() * _e->radius())) / _n;
|
||||
qc = 1 - ((_one_minus_es2) / (_two_es)) * log((1.0 - _es) / (1.0 + _es));
|
||||
if (fabs(fabs(qc) - fabs(q)) > 1.0e-6) {
|
||||
q_over_2 = q / 2.0;
|
||||
|
@ -2,20 +2,22 @@
|
||||
#define ALBERSEQUAL_H
|
||||
|
||||
#include "ellipsoid.h"
|
||||
#include "projection.h"
|
||||
#include "ct.h"
|
||||
|
||||
class AlbersEqual : public Projection
|
||||
class AlbersEqual : public CT
|
||||
{
|
||||
public:
|
||||
AlbersEqual(const Ellipsoid &ellipsoid, double standardParallel1,
|
||||
AlbersEqual(const Ellipsoid *ellipsoid, double standardParallel1,
|
||||
double standardParallel2, double latitudeOrigin, double longitudeOrigin,
|
||||
double falseEasting, double falseNorthing);
|
||||
|
||||
virtual CT *clone() const {return new AlbersEqual(*this);}
|
||||
|
||||
virtual QPointF ll2xy(const Coordinates &c) const;
|
||||
virtual Coordinates xy2ll(const QPointF &p) const;
|
||||
|
||||
private:
|
||||
Ellipsoid _e;
|
||||
const Ellipsoid *_e;
|
||||
|
||||
double _latitudeOrigin;
|
||||
double _longitudeOrigin;
|
||||
|
90
src/map/angularunits.cpp
Normal file
90
src/map/angularunits.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
#include "common/coordinates.h"
|
||||
#include "common/str2int.h"
|
||||
#include "angularunits.h"
|
||||
|
||||
static double sDMS2deg(double val)
|
||||
{
|
||||
double angle;
|
||||
const char *decimal;
|
||||
|
||||
QString qstr(QString::number(qAbs(val), 'f', 7));
|
||||
const char *str = qstr.toLatin1().constData();
|
||||
decimal = strrchr(str, '.');
|
||||
int deg = str2int(str, decimal - str);
|
||||
int min = str2int(decimal + 1, 2);
|
||||
int sec = str2int(decimal + 3, 2);
|
||||
int f = str2int(decimal + 5, 3);
|
||||
|
||||
angle = deg + min/60.0 + sec/3600.0 + (f/1000.0)/3600.0;
|
||||
|
||||
return (val < 0) ? -angle : angle;
|
||||
}
|
||||
|
||||
static double deg2sDMS(double val)
|
||||
{
|
||||
double aval = qAbs(val);
|
||||
|
||||
int deg = aval;
|
||||
double r1 = aval - deg;
|
||||
|
||||
int min = r1 * 60.0;
|
||||
double r2 = r1 - (min / 60.0);
|
||||
|
||||
int sec = r2 * 3600.0;
|
||||
double r3 = r2 - (sec / 3600.0);
|
||||
int f = (int)(r3 * 3600.0 * 1000.0);
|
||||
|
||||
QString str(QString("%1.%2%3%4").arg(deg).arg(min, 2, 10, QChar('0'))
|
||||
.arg(sec, 2, 10, QChar('0')).arg(f, 3, 10, QChar('0')));
|
||||
|
||||
return (val < 0) ? -str.toDouble() : str.toDouble();
|
||||
}
|
||||
|
||||
AngularUnits::AngularUnits(int code) : _code(code)
|
||||
{
|
||||
switch (code) {
|
||||
case 9101:
|
||||
_f = 180.0 / M_PI;
|
||||
break;
|
||||
case 9102:
|
||||
case 9107:
|
||||
case 9108:
|
||||
case 9110:
|
||||
case 9122:
|
||||
_f = 1.0;
|
||||
break;
|
||||
case 9103:
|
||||
_f = 1 / 60.0;
|
||||
break;
|
||||
case 9104:
|
||||
_f = 1 / 3600.0;
|
||||
break;
|
||||
case 9105:
|
||||
_f = 180.0 / 200.0;
|
||||
break;
|
||||
case 9106:
|
||||
_f = 180.0 / 200.0;
|
||||
break;
|
||||
case 9109:
|
||||
_f = 180.0 / (M_PI * 1000000.0);
|
||||
break;
|
||||
default:
|
||||
_f = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
double AngularUnits::toDegrees(double val) const
|
||||
{
|
||||
return (_code == 9110) ? sDMS2deg(val) : val * _f;
|
||||
}
|
||||
|
||||
double AngularUnits::fromDegrees(double val) const
|
||||
{
|
||||
return (_code == 9110) ? deg2sDMS(val) : val / _f;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const AngularUnits &au)
|
||||
{
|
||||
dbg.nospace() << "AngularUnits(" << deg2rad(au._f) << ")";
|
||||
return dbg.space();
|
||||
}
|
32
src/map/angularunits.h
Normal file
32
src/map/angularunits.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef ANGULARUNITS_H
|
||||
#define ANGULARUNITS_H
|
||||
|
||||
#include <cmath>
|
||||
#include <QDebug>
|
||||
|
||||
class AngularUnits
|
||||
{
|
||||
public:
|
||||
AngularUnits() : _code(0), _f(NAN) {}
|
||||
AngularUnits(int code);
|
||||
|
||||
bool isNull() const {return std::isnan(_f);}
|
||||
bool isValid() const {return !std::isnan(_f);}
|
||||
|
||||
double toDegrees(double val) const;
|
||||
double fromDegrees(double val) const;
|
||||
|
||||
friend bool operator==(const AngularUnits &au1, const AngularUnits &au2);
|
||||
friend QDebug operator<<(QDebug dbg, const AngularUnits &au);
|
||||
|
||||
private:
|
||||
int _code;
|
||||
double _f;
|
||||
};
|
||||
|
||||
inline bool operator==(const AngularUnits &au1, const AngularUnits &au2)
|
||||
{return (au1._f == au2._f);}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const AngularUnits &au);
|
||||
|
||||
#endif // ANGULARUNITS_H
|
@ -31,37 +31,6 @@ static bool yCmp(const OfflineMap *m1, const OfflineMap *m2)
|
||||
return TL(m1).y() > TL(m2).y();
|
||||
}
|
||||
|
||||
bool Atlas::isAtlas(Tar &tar, const QString &path)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
QByteArray ba;
|
||||
QString suffix = fi.suffix().toLower();
|
||||
|
||||
if (suffix == "tar") {
|
||||
if (!tar.load(path)) {
|
||||
_errorString = "Error reading tar file";
|
||||
return false;
|
||||
}
|
||||
QString tbaFileName = fi.completeBaseName() + ".tba";
|
||||
ba = tar.file(tbaFileName);
|
||||
} else if (suffix == "tba") {
|
||||
QFile tbaFile(path);
|
||||
if (!tbaFile.open(QIODevice::ReadOnly)) {
|
||||
_errorString = QString("Error opening tba file: %1")
|
||||
.arg(tbaFile.errorString());
|
||||
return false;
|
||||
}
|
||||
ba = tbaFile.readAll();
|
||||
}
|
||||
|
||||
if (ba.startsWith("Atlas 1.0"))
|
||||
return true;
|
||||
else {
|
||||
_errorString = "Missing or invalid tba file";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Atlas::computeZooms()
|
||||
{
|
||||
qSort(_maps.begin(), _maps.end(), resCmp);
|
||||
@ -111,16 +80,38 @@ void Atlas::computeBounds()
|
||||
|
||||
Atlas::Atlas(const QString &fileName, QObject *parent) : Map(parent)
|
||||
{
|
||||
Tar tar;
|
||||
QFileInfo fi(fileName);
|
||||
QByteArray ba;
|
||||
QString suffix = fi.suffix().toLower();
|
||||
Tar tar;
|
||||
|
||||
_valid = false;
|
||||
_zoom = 0;
|
||||
_name = fi.dir().dirName();
|
||||
_ci = -1; _cz = -1;
|
||||
|
||||
if (!isAtlas(tar, fileName))
|
||||
|
||||
if (suffix == "tar") {
|
||||
if (!tar.load(fileName)) {
|
||||
_errorString = "Error reading tar file";
|
||||
return;
|
||||
}
|
||||
QString tbaFileName = fi.completeBaseName() + ".tba";
|
||||
ba = tar.file(tbaFileName);
|
||||
} else if (suffix == "tba") {
|
||||
QFile tbaFile(fileName);
|
||||
if (!tbaFile.open(QIODevice::ReadOnly)) {
|
||||
_errorString = QString("Error opening tba file: %1")
|
||||
.arg(tbaFile.errorString());
|
||||
return;
|
||||
}
|
||||
ba = tbaFile.readAll();
|
||||
}
|
||||
if (!ba.startsWith("Atlas 1.0")) {
|
||||
_errorString = "Missing or invalid tba file";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QDir dir(fi.absolutePath());
|
||||
QFileInfoList layers = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
@ -336,3 +327,20 @@ void Atlas::unload()
|
||||
for (int i = 0; i < _maps.count(); i++)
|
||||
_maps.at(i)->unload();
|
||||
}
|
||||
|
||||
bool Atlas::isAtlas(const QString &path)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
QString suffix = fi.suffix().toLower();
|
||||
Tar tar;
|
||||
|
||||
if (suffix == "tar") {
|
||||
if (!tar.load(path))
|
||||
return false;
|
||||
QString tbaFileName = fi.completeBaseName() + ".tba";
|
||||
return tar.contains(tbaFileName);
|
||||
} else if (suffix == "tba")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -35,9 +35,10 @@ public:
|
||||
bool isValid() const {return _valid;}
|
||||
const QString &errorString() const {return _errorString;}
|
||||
|
||||
static bool isAtlas(const QString &path);
|
||||
|
||||
private:
|
||||
void draw(QPainter *painter, const QRectF &rect, int mapIndex);
|
||||
bool isAtlas(Tar &tar, const QString &path);
|
||||
void computeZooms();
|
||||
void computeBounds();
|
||||
|
||||
|
17
src/map/ct.h
Normal file
17
src/map/ct.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef CT_H
|
||||
#define CT_H
|
||||
|
||||
#include <QPointF>
|
||||
#include "common/coordinates.h"
|
||||
|
||||
class CT {
|
||||
public:
|
||||
virtual ~CT() {}
|
||||
|
||||
virtual CT *clone() const = 0;
|
||||
|
||||
virtual QPointF ll2xy(const Coordinates &c) const = 0;
|
||||
virtual Coordinates xy2ll(const QPointF &p) const = 0;
|
||||
};
|
||||
|
||||
#endif // CT_H
|
@ -1,96 +1,14 @@
|
||||
#include <cmath>
|
||||
#include <QFile>
|
||||
#include "common/wgs84.h"
|
||||
#include "datum.h"
|
||||
|
||||
|
||||
static QMap<QString, Datum> WGS84()
|
||||
{
|
||||
QMap<QString, Datum> map;
|
||||
map.insert("WGS 84", Datum(Ellipsoid(WGS84_RADIUS, WGS84_FLATTENING),
|
||||
0.0, 0.0, 0.0));
|
||||
return map;
|
||||
}
|
||||
|
||||
QMap<QString, Datum> Datum::_datums = WGS84();
|
||||
QString Datum::_errorString;
|
||||
int Datum::_errorLine = 0;
|
||||
|
||||
Datum Datum::datum(const QString &name)
|
||||
{
|
||||
QMap<QString, Datum>::const_iterator it = _datums.find(name);
|
||||
|
||||
if (it == _datums.end())
|
||||
return Datum();
|
||||
|
||||
return it.value();
|
||||
}
|
||||
|
||||
bool Datum::loadList(const QString &path)
|
||||
{
|
||||
QFile file(path);
|
||||
bool res;
|
||||
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
_errorString = qPrintable(file.errorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
_errorLine = 1;
|
||||
_errorString.clear();
|
||||
|
||||
while (!file.atEnd()) {
|
||||
QByteArray line = file.readLine();
|
||||
QList<QByteArray> list = line.split(',');
|
||||
if (list.size() != 6) {
|
||||
_errorString = "Format error";
|
||||
return false;
|
||||
}
|
||||
|
||||
int eid = list[2].trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid ellipsoid id";
|
||||
return false;
|
||||
}
|
||||
double dx = list[3].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid dx";
|
||||
return false;
|
||||
}
|
||||
double dy = list[4].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid dy";
|
||||
return false;
|
||||
}
|
||||
double dz = list[5].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid dz";
|
||||
return false;
|
||||
}
|
||||
|
||||
Ellipsoid e = Ellipsoid::ellipsoid(eid);
|
||||
if (e.isNull()) {
|
||||
_errorString = "Unknown ellipsoid ID";
|
||||
return false;
|
||||
}
|
||||
|
||||
Datum d(e, dx, dy, dz);
|
||||
_datums.insert(list[0].trimmed(), d);
|
||||
|
||||
_errorLine++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
static Ellipsoid WGS84e = Ellipsoid(WGS84_RADIUS, WGS84_FLATTENING);
|
||||
static Datum WGS84 = Datum(&WGS84e, 0.0, 0.0, 0.0);
|
||||
|
||||
// Abridged Molodensky transformation
|
||||
Coordinates Datum::toWGS84(const Coordinates &c) const
|
||||
static Coordinates molodensky(const Coordinates &c, const Datum &from,
|
||||
const Datum &to)
|
||||
{
|
||||
if (_ellipsoid.radius() == WGS84_RADIUS
|
||||
&& _ellipsoid.flattening() == WGS84_FLATTENING
|
||||
&& _dx == 0.0 && _dy == 0.0 && _dz == 0.0)
|
||||
return c;
|
||||
|
||||
double rlat = deg2rad(c.lat());
|
||||
double rlon = deg2rad(c.lon());
|
||||
|
||||
@ -100,21 +18,52 @@ Coordinates Datum::toWGS84(const Coordinates &c) const
|
||||
double clon = cos(rlon);
|
||||
double ssqlat = slat * slat;
|
||||
|
||||
double from_f = ellipsoid().flattening();
|
||||
double df = WGS84_FLATTENING - from_f;
|
||||
double from_a = ellipsoid().radius();
|
||||
double da = WGS84_RADIUS - from_a;
|
||||
double from_esq = ellipsoid().flattening()
|
||||
* (2.0 - ellipsoid().flattening());
|
||||
double dx = from.dx() - to.dx();
|
||||
double dy = from.dy() - to.dy();
|
||||
double dz = from.dz() - to.dz();
|
||||
|
||||
double from_f = from.ellipsoid()->flattening();
|
||||
double to_f = to.ellipsoid()->flattening();
|
||||
double df = to_f - from_f;
|
||||
double from_a = from.ellipsoid()->radius();
|
||||
double to_a = to.ellipsoid()->radius();
|
||||
double da = to_a - from_a;
|
||||
double from_esq = from_f * (2.0 - from_f);
|
||||
double adb = 1.0 / (1.0 - from_f);
|
||||
double rn = from_a / sqrt(1 - from_esq * ssqlat);
|
||||
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
|
||||
* clat) / (rm + from_h);
|
||||
double dlon = (-dx() * slon + dy() * clon) / ((rn + from_h) * clat);
|
||||
|
||||
double dlon = (-dx * slon + dy * clon) / ((rn + from_h) * clat);
|
||||
|
||||
return Coordinates(c.lon() + rad2deg(dlon), c.lat() + rad2deg(dlat));
|
||||
}
|
||||
|
||||
Datum::Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz)
|
||||
: _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz)
|
||||
{
|
||||
_WGS84 = (_ellipsoid->radius() == WGS84_RADIUS
|
||||
&& _ellipsoid->flattening() == WGS84_FLATTENING && _dx == 0.0
|
||||
&& _dy == 0.0 && _dz == 0.0) ? true : false;
|
||||
}
|
||||
|
||||
Coordinates Datum::toWGS84(const Coordinates &c) const
|
||||
{
|
||||
return _WGS84 ? c : molodensky(c, *this, WGS84);
|
||||
}
|
||||
|
||||
Coordinates Datum::fromWGS84(const Coordinates &c) const
|
||||
{
|
||||
return _WGS84 ? c : molodensky(c, WGS84, *this);
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Datum &datum)
|
||||
{
|
||||
dbg.nospace() << "Datum(" << *datum.ellipsoid() << ", " << datum.dx()
|
||||
<< ", " << datum.dy() << ", " << datum.dz() << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
|
@ -1,40 +1,44 @@
|
||||
#ifndef DATUM_H
|
||||
#define DATUM_H
|
||||
|
||||
#include <QMap>
|
||||
#include <cmath>
|
||||
#include <QList>
|
||||
#include <QDebug>
|
||||
#include "ellipsoid.h"
|
||||
#include "common/coordinates.h"
|
||||
|
||||
class Datum
|
||||
{
|
||||
public:
|
||||
Datum() : _ellipsoid(Ellipsoid()), _dx(0.0), _dy(0.0), _dz(0.0) {}
|
||||
Datum(const Ellipsoid &ellipsoid, double dx, double dy, double dz)
|
||||
: _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz) {}
|
||||
Datum() : _ellipsoid(0), _dx(NAN), _dy(NAN), _dz(NAN),
|
||||
_WGS84(false) {}
|
||||
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 dy() const {return _dy;}
|
||||
double dz() const {return _dz;}
|
||||
|
||||
bool isNull() const
|
||||
{return (_ellipsoid.isNull() && _dx == 0.0 && _dy == 0.0 && _dz == 0.0);}
|
||||
{return (!_ellipsoid && std::isnan(_dx) && std::isnan(_dy)
|
||||
&& std::isnan(_dz));}
|
||||
bool isValid() const
|
||||
{return (_ellipsoid && !std::isnan(_dx) && !std::isnan(_dy)
|
||||
&& !std::isnan(_dz));}
|
||||
|
||||
Coordinates toWGS84(const Coordinates &c) const;
|
||||
|
||||
static bool loadList(const QString &path);
|
||||
static const QString &errorString() {return _errorString;}
|
||||
static int errorLine() {return _errorLine;}
|
||||
|
||||
static Datum datum(const QString &name);
|
||||
Coordinates fromWGS84(const Coordinates &c) const;
|
||||
|
||||
private:
|
||||
Ellipsoid _ellipsoid;
|
||||
const Ellipsoid *_ellipsoid;
|
||||
double _dx, _dy, _dz;
|
||||
|
||||
static QMap<QString, Datum> _datums;
|
||||
static QString _errorString;
|
||||
static int _errorLine;
|
||||
bool _WGS84;
|
||||
};
|
||||
|
||||
inline bool operator==(const Datum &d1, const Datum &d2)
|
||||
{return (d1.ellipsoid() == d2.ellipsoid() && d1.dx() == d2.dx()
|
||||
&& d1.dy() == d2.dy() && d1.dz() == d2.dz());}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Datum &datum);
|
||||
|
||||
#endif // DATUM_H
|
||||
|
@ -1,62 +1,74 @@
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include "common/wgs84.h"
|
||||
#include "ellipsoid.h"
|
||||
|
||||
QMap<int, Ellipsoid> Ellipsoid::_ellipsoids;
|
||||
QString Ellipsoid::_errorString;
|
||||
int Ellipsoid::_errorLine = 0;
|
||||
QMap<int, Ellipsoid> Ellipsoid::_ellipsoids = WGS84();
|
||||
|
||||
Ellipsoid Ellipsoid::ellipsoid(int id)
|
||||
QMap<int, Ellipsoid> Ellipsoid::WGS84()
|
||||
{
|
||||
QMap<int, Ellipsoid> map;
|
||||
map.insert(7030, Ellipsoid(WGS84_RADIUS, WGS84_FLATTENING));
|
||||
return map;
|
||||
}
|
||||
|
||||
const Ellipsoid *Ellipsoid::ellipsoid(int id)
|
||||
{
|
||||
QMap<int, Ellipsoid>::const_iterator it = _ellipsoids.find(id);
|
||||
|
||||
if (it == _ellipsoids.end())
|
||||
return Ellipsoid();
|
||||
|
||||
return it.value();
|
||||
return 0;
|
||||
else
|
||||
return &(it.value());
|
||||
}
|
||||
|
||||
bool Ellipsoid::loadList(const QString &path)
|
||||
void Ellipsoid::loadList(const QString &path)
|
||||
{
|
||||
QFile file(path);
|
||||
bool res;
|
||||
int ln = 0;
|
||||
|
||||
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
_errorString = qPrintable(file.errorString());
|
||||
return false;
|
||||
qWarning("Error opening ellipsoids file: %s: %s", qPrintable(path),
|
||||
qPrintable(file.errorString()));
|
||||
return;
|
||||
}
|
||||
|
||||
_errorLine = 1;
|
||||
_errorString.clear();
|
||||
|
||||
while (!file.atEnd()) {
|
||||
ln++;
|
||||
|
||||
QByteArray line = file.readLine();
|
||||
QList<QByteArray> list = line.split(',');
|
||||
if (list.size() != 4) {
|
||||
_errorString = "Format error";
|
||||
return false;
|
||||
qWarning("%s: %d: Format error", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = list[0].trimmed().toInt(&res);
|
||||
int id = list[1].trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid ellipsoid id";
|
||||
return false;
|
||||
qWarning("%s: %d: Invalid ellipsoid code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
double radius = list[2].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid ellipsoid radius";
|
||||
return false;
|
||||
qWarning("%s: %d: Invalid radius", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
double flattening = list[3].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid ellipsoid flattening";
|
||||
return false;
|
||||
qWarning("%s: %d: Invalid flattening", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
|
||||
Ellipsoid e(radius, 1.0/flattening);
|
||||
_ellipsoids.insert(id, e);
|
||||
|
||||
_errorLine++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Ellipsoid &ellipsoid)
|
||||
{
|
||||
dbg.nospace() << "Ellipsoid(" << ellipsoid.radius() << ", "
|
||||
<< 1.0 / ellipsoid.flattening() << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
|
@ -1,34 +1,40 @@
|
||||
#ifndef ELLIPSOID_H
|
||||
#define ELLIPSOID_H
|
||||
|
||||
#include <cmath>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QDebug>
|
||||
|
||||
class Ellipsoid
|
||||
{
|
||||
public:
|
||||
Ellipsoid() : _radius(0.0), _flattening(0.0) {}
|
||||
Ellipsoid() : _radius(NAN), _flattening(NAN) {}
|
||||
Ellipsoid(double radius, double flattening)
|
||||
: _radius(radius), _flattening(flattening) {}
|
||||
|
||||
double radius() const {return _radius;}
|
||||
double flattening() const {return _flattening;}
|
||||
|
||||
bool isNull() const {return (_radius == 0.0 && _flattening == 0.0);}
|
||||
bool isNull() const
|
||||
{return (std::isnan(_radius) && std::isnan(_flattening));}
|
||||
bool isValid() const
|
||||
{return !(std::isnan(_radius) || std::isnan(_flattening));}
|
||||
|
||||
static bool loadList(const QString &path);
|
||||
static const QString &errorString() {return _errorString;}
|
||||
static int errorLine() {return _errorLine;}
|
||||
|
||||
static Ellipsoid ellipsoid(int id);
|
||||
static const Ellipsoid *ellipsoid(int id);
|
||||
static void loadList(const QString &path);
|
||||
|
||||
private:
|
||||
double _radius;
|
||||
double _flattening;
|
||||
|
||||
static QMap<int, Ellipsoid> WGS84();
|
||||
static QMap<int, Ellipsoid> _ellipsoids;
|
||||
static QString _errorString;
|
||||
static int _errorLine;
|
||||
};
|
||||
|
||||
inline bool operator==(const Ellipsoid &e1, const Ellipsoid &e2)
|
||||
{return (e1.radius() == e2.radius() && e1.flattening() == e2.flattening());}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Ellipsoid &ellipsoid);
|
||||
|
||||
#endif // ELLIPSOID_H
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "common/rectc.h"
|
||||
#include "common/wgs84.h"
|
||||
#include "mercator.h"
|
||||
#include "misc.h"
|
||||
#include "emptymap.h"
|
||||
|
||||
|
||||
@ -18,7 +17,7 @@ EmptyMap::EmptyMap(QObject *parent) : Map(parent)
|
||||
|
||||
QRectF EmptyMap::bounds() const
|
||||
{
|
||||
return scaled(QRectF(QPointF(-180, -180), QSizeF(360, 360)), 1.0/_scale);
|
||||
return QRectF(ll2xy(Coordinates(-180, 85)), ll2xy(Coordinates(180, -85)));
|
||||
}
|
||||
|
||||
qreal EmptyMap::zoomFit(const QSize &size, const RectC &br)
|
||||
@ -72,13 +71,13 @@ void EmptyMap::draw(QPainter *painter, const QRectF &rect)
|
||||
painter->fillRect(rect, _backgroundColor);
|
||||
}
|
||||
|
||||
QPointF EmptyMap::ll2xy(const Coordinates &c)
|
||||
QPointF EmptyMap::ll2xy(const Coordinates &c) const
|
||||
{
|
||||
QPointF m = Mercator().ll2xy(c);
|
||||
return QPointF(m.x() / _scale, m.y() / -_scale);
|
||||
}
|
||||
|
||||
Coordinates EmptyMap::xy2ll(const QPointF &p)
|
||||
Coordinates EmptyMap::xy2ll(const QPointF &p) const
|
||||
{
|
||||
QPointF m(p.x() * _scale, -p.y() * _scale);
|
||||
return Mercator().xy2ll(m);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef EMPTYMAP_H
|
||||
#define EMPTYMAP_H
|
||||
|
||||
#include "common/coordinates.h"
|
||||
#include "map.h"
|
||||
|
||||
class EmptyMap : public Map
|
||||
@ -21,12 +22,17 @@ public:
|
||||
qreal zoomIn();
|
||||
qreal zoomOut();
|
||||
|
||||
QPointF ll2xy(const Coordinates &c);
|
||||
Coordinates xy2ll(const QPointF &p);
|
||||
QPointF ll2xy(const Coordinates &c)
|
||||
{return static_cast<const EmptyMap &>(*this).ll2xy(c);}
|
||||
Coordinates xy2ll(const QPointF &p)
|
||||
{return static_cast<const EmptyMap &>(*this).xy2ll(p);}
|
||||
|
||||
void draw(QPainter *painter, const QRectF &rect);
|
||||
|
||||
private:
|
||||
QPointF ll2xy(const Coordinates &c) const;
|
||||
Coordinates xy2ll(const QPointF &p) const;
|
||||
|
||||
QString _name;
|
||||
qreal _scale;
|
||||
};
|
||||
|
191
src/map/gcs.cpp
Normal file
191
src/map/gcs.cpp
Normal file
@ -0,0 +1,191 @@
|
||||
#include <QFile>
|
||||
#include "common/wgs84.h"
|
||||
#include "gcs.h"
|
||||
|
||||
|
||||
class GCS::Entry {
|
||||
public:
|
||||
Entry(int id, int gd, const QString &name, const GCS &gcs)
|
||||
: _id(id), _gd(gd), _name(name), _gcs(gcs) {}
|
||||
|
||||
int id() const {return _id;}
|
||||
int gd() const {return _gd;}
|
||||
const QString &name() const {return _name;}
|
||||
const GCS &gcs() const {return _gcs;}
|
||||
|
||||
private:
|
||||
int _id, _gd;
|
||||
QString _name;
|
||||
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)
|
||||
{
|
||||
QString field = str.trimmed();
|
||||
if (field.isEmpty()) {
|
||||
*res = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return field.toInt(res);
|
||||
}
|
||||
|
||||
QList<GCS::Entry> GCS::_gcss = WGS84();
|
||||
|
||||
QList<GCS::Entry> GCS::WGS84()
|
||||
{
|
||||
QList<GCS::Entry> list;
|
||||
list.append(GCS::Entry(4326, 6326, "WGS 84", GCS(WGS84d, 8901, 9122)));
|
||||
return list;
|
||||
}
|
||||
|
||||
const GCS *GCS::gcs(int id)
|
||||
{
|
||||
for (int i = 0; i < _gcss.size(); i++)
|
||||
if (_gcss.at(i).id() == id)
|
||||
return &(_gcss.at(i).gcs());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const GCS *GCS::gcs(int geodeticDatum, int primeMeridian, int angularUnits)
|
||||
{
|
||||
for (int i = 0; i < _gcss.size(); i++) {
|
||||
const Entry &e = _gcss.at(i);
|
||||
if (e.gd() == geodeticDatum && e.gcs().primeMeridian() == primeMeridian
|
||||
&& e.gcs().angularUnits() == angularUnits)
|
||||
return &(e.gcs());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const GCS *GCS::gcs(const QString &name)
|
||||
{
|
||||
for (int i = 0; i < _gcss.size(); i++)
|
||||
if (_gcss.at(i).name() == name)
|
||||
return &(_gcss.at(i).gcs());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GCS::loadList(const QString &path)
|
||||
{
|
||||
QFile file(path);
|
||||
bool res;
|
||||
int ln = 0;
|
||||
const Ellipsoid *e;
|
||||
|
||||
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
qWarning("Error opening PCS file: %s: %s", qPrintable(path),
|
||||
qPrintable(file.errorString()));
|
||||
return;
|
||||
}
|
||||
|
||||
while (!file.atEnd()) {
|
||||
ln++;
|
||||
|
||||
QByteArray line = file.readLine();
|
||||
QList<QByteArray> list = line.split(',');
|
||||
if (list.size() < 10) {
|
||||
qWarning("%s: %d: Format error", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = parameter(list[1], &res);
|
||||
if (!res) {
|
||||
qWarning("%s: %d: Invalid GCS code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
int gd = parameter(list[2], &res);
|
||||
if (!res) {
|
||||
qWarning("%s: %d: Invalid geodetic datum code", qPrintable(path),
|
||||
ln);
|
||||
continue;
|
||||
}
|
||||
int au = list[3].trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s: %d: Invalid angular units code", qPrintable(path),
|
||||
ln);
|
||||
continue;
|
||||
}
|
||||
int el = list[4].trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s: %d: Invalid ellipsoid code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
int pm = list[5].trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s: %d: Invalid prime meridian code", qPrintable(path),
|
||||
ln);
|
||||
continue;
|
||||
}
|
||||
int ct = list[6].trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s: %d: Invalid coordinates transformation code",
|
||||
qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
double dx = list[7].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
qWarning("%s: %d: Invalid dx", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
double dy = list[8].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
qWarning("%s: %d: Invalid dy", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
double dz = list[9].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
qWarning("%s: %d: Invalid dz", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(e = Ellipsoid::ellipsoid(el))) {
|
||||
qWarning("%s: %d: Unknown ellipsoid code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
|
||||
Datum datum;
|
||||
switch (ct) {
|
||||
case 9603:
|
||||
datum = Datum(e, dx, dy, dz);
|
||||
break;
|
||||
default:
|
||||
qWarning("%s: %d: Unknown coordinates transformation method",
|
||||
qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
|
||||
GCS gcs(datum, pm, au);
|
||||
if (gcs.isValid())
|
||||
_gcss.append(Entry(id, gd, list[0].trimmed(), gcs));
|
||||
else
|
||||
qWarning("%s: %d: Unknown prime meridian/angular units code",
|
||||
qPrintable(path), ln);
|
||||
}
|
||||
}
|
||||
|
||||
Coordinates GCS::toWGS84(const Coordinates &c) const
|
||||
{
|
||||
return datum().toWGS84(Coordinates(_primeMeridian.toGreenwich(c.lon()),
|
||||
c.lat()));
|
||||
}
|
||||
|
||||
Coordinates GCS::fromWGS84(const Coordinates &c) const
|
||||
{
|
||||
Coordinates ds(datum().fromWGS84(c));
|
||||
return Coordinates(_primeMeridian.fromGreenwich(ds.lon()), ds.lat());
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const GCS &gcs)
|
||||
{
|
||||
dbg.nospace() << "GCS(" << gcs.datum() << ", " << gcs.primeMeridian()
|
||||
<< ", " << gcs.angularUnits() << ")";
|
||||
return dbg.space();
|
||||
}
|
55
src/map/gcs.h
Normal file
55
src/map/gcs.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef GCS_H
|
||||
#define GCS_H
|
||||
|
||||
#include "datum.h"
|
||||
#include "angularunits.h"
|
||||
#include "primemeridian.h"
|
||||
|
||||
class GCS
|
||||
{
|
||||
public:
|
||||
GCS() {}
|
||||
GCS(const Datum &datum, const PrimeMeridian &primeMeridian,
|
||||
const AngularUnits &angularUnits) : _datum(datum),
|
||||
_primeMeridian(primeMeridian), _angularUnits(angularUnits) {}
|
||||
|
||||
const PrimeMeridian &primeMeridian() const {return _primeMeridian;}
|
||||
const AngularUnits &angularUnits() const {return _angularUnits;}
|
||||
const Datum &datum() const {return _datum;}
|
||||
|
||||
bool isNull() const {return _datum.isNull() && _angularUnits.isNull()
|
||||
&& _primeMeridian.isNull();}
|
||||
bool isValid() const {return _datum.isValid() && _angularUnits.isValid()
|
||||
&& _primeMeridian.isValid();}
|
||||
|
||||
Coordinates toWGS84(const Coordinates &c) const;
|
||||
Coordinates fromWGS84(const Coordinates &c) const;
|
||||
|
||||
|
||||
static const GCS *gcs(int id);
|
||||
static const GCS *gcs(int geodeticDatum, int primeMeridian,
|
||||
int angularUnits);
|
||||
static const GCS *gcs(const QString &name);
|
||||
|
||||
static void loadList(const QString &path);
|
||||
|
||||
private:
|
||||
class Entry;
|
||||
|
||||
static QList<Entry> WGS84();
|
||||
|
||||
Datum _datum;
|
||||
PrimeMeridian _primeMeridian;
|
||||
AngularUnits _angularUnits;
|
||||
|
||||
static QList<Entry> _gcss;
|
||||
};
|
||||
|
||||
inline bool operator==(const GCS &gcs1, const GCS &gcs2)
|
||||
{return (gcs1.datum() == gcs2.datum()
|
||||
&& gcs1.primeMeridian() == gcs2.primeMeridian()
|
||||
&& gcs1.angularUnits() == gcs2.angularUnits());}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const GCS &gcs);
|
||||
|
||||
#endif // GCS_H
|
484
src/map/geotiff.cpp
Normal file
484
src/map/geotiff.cpp
Normal file
@ -0,0 +1,484 @@
|
||||
#include <QFileInfo>
|
||||
#include <QtEndian>
|
||||
#include "pcs.h"
|
||||
#include "latlon.h"
|
||||
#include "geotiff.h"
|
||||
|
||||
|
||||
#define TIFF_DOUBLE 12
|
||||
#define TIFF_SHORT 3
|
||||
#define TIFF_LONG 4
|
||||
|
||||
#define ModelPixelScaleTag 33550
|
||||
#define ModelTiepointTag 33922
|
||||
#define ModelTransformationTag 34264
|
||||
#define GeoKeyDirectoryTag 34735
|
||||
#define GeoDoubleParamsTag 34736
|
||||
#define ImageWidth 256
|
||||
#define ImageHeight 257
|
||||
|
||||
#define GTModelTypeGeoKey 1024
|
||||
#define GTRasterTypeGeoKey 1025
|
||||
#define GeographicTypeGeoKey 2048
|
||||
#define GeogGeodeticDatumGeoKey 2050
|
||||
#define GeogPrimeMeridianGeoKey 2051
|
||||
#define GeogAngularUnitsGeoKey 2054
|
||||
#define ProjectedCSTypeGeoKey 3072
|
||||
#define ProjectionGeoKey 3074
|
||||
#define ProjCoordTransGeoKey 3075
|
||||
#define ProjLinearUnitsGeoKey 3076
|
||||
#define ProjStdParallel1GeoKey 3078
|
||||
#define ProjStdParallel2GeoKey 3079
|
||||
#define ProjNatOriginLongGeoKey 3080
|
||||
#define ProjNatOriginLatGeoKey 3081
|
||||
#define ProjFalseEastingGeoKey 3082
|
||||
#define ProjFalseNorthingGeoKey 3083
|
||||
#define ProjScaleAtNatOriginGeoKey 3092
|
||||
|
||||
#define ModelTypeProjected 1
|
||||
#define ModelTypeGeographic 2
|
||||
#define ModelTypeGeocentric 3
|
||||
|
||||
#define IS_SET(map, key) \
|
||||
((map).contains(key) && (map).value(key).SHORT != 32767)
|
||||
|
||||
#define ARRAY_SIZE(a) \
|
||||
(sizeof(a) / sizeof(*a))
|
||||
|
||||
typedef struct {
|
||||
quint16 KeyDirectoryVersion;
|
||||
quint16 KeyRevision;
|
||||
quint16 MinorRevision;
|
||||
quint16 NumberOfKeys;
|
||||
} Header;
|
||||
|
||||
typedef struct {
|
||||
quint16 KeyID;
|
||||
quint16 TIFFTagLocation;
|
||||
quint16 Count;
|
||||
quint16 ValueOffset;
|
||||
} KeyEntry;
|
||||
|
||||
|
||||
bool GeoTIFF::readEntry(TIFFFile &file, Ctx &ctx) const
|
||||
{
|
||||
quint16 tag;
|
||||
quint16 type;
|
||||
quint32 count, offset;
|
||||
|
||||
if (!file.readValue(tag))
|
||||
return false;
|
||||
if (!file.readValue(type))
|
||||
return false;
|
||||
if (!file.readValue(count))
|
||||
return false;
|
||||
if (!file.readValue(offset))
|
||||
return false;
|
||||
|
||||
switch (tag) {
|
||||
case ModelPixelScaleTag:
|
||||
if (type != TIFF_DOUBLE || count != 3)
|
||||
return false;
|
||||
ctx.scale = offset;
|
||||
break;
|
||||
case ModelTiepointTag:
|
||||
if (type != TIFF_DOUBLE || count < 6 || count % 6)
|
||||
return false;
|
||||
ctx.tiepoints = offset;
|
||||
ctx.tiepointCount = count / 6;
|
||||
break;
|
||||
case GeoKeyDirectoryTag:
|
||||
if (type != TIFF_SHORT)
|
||||
return false;
|
||||
ctx.keys = offset;
|
||||
break;
|
||||
case GeoDoubleParamsTag:
|
||||
if (type != TIFF_DOUBLE)
|
||||
return false;
|
||||
ctx.values = offset;
|
||||
break;
|
||||
case ModelTransformationTag:
|
||||
if (type != TIFF_DOUBLE || count != 16)
|
||||
return false;
|
||||
ctx.matrix = offset;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GeoTIFF::readIFD(TIFFFile &file, quint32 &offset, Ctx &ctx) const
|
||||
{
|
||||
quint16 count;
|
||||
|
||||
if (!file.seek(offset))
|
||||
return false;
|
||||
if (!file.readValue(count))
|
||||
return false;
|
||||
|
||||
for (quint16 i = 0; i < count; i++)
|
||||
if (!readEntry(file, ctx))
|
||||
return false;
|
||||
|
||||
if (!file.readValue(offset))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GeoTIFF::readScale(TIFFFile &file, quint32 offset, QPointF &scale) const
|
||||
{
|
||||
if (!file.seek(offset))
|
||||
return false;
|
||||
|
||||
if (!file.readValue(scale.rx()))
|
||||
return false;
|
||||
if (!file.readValue(scale.ry()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GeoTIFF::readTiepoints(TIFFFile &file, quint32 offset, quint32 count,
|
||||
QList<ReferencePoint> &points) const
|
||||
{
|
||||
double z, pz;
|
||||
QPointF xy, pp;
|
||||
|
||||
if (!file.seek(offset))
|
||||
return false;
|
||||
|
||||
for (quint32 i = 0; i < count; i++) {
|
||||
if (!file.readValue(xy.rx()))
|
||||
return false;
|
||||
if (!file.readValue(xy.ry()))
|
||||
return false;
|
||||
if (!file.readValue(z))
|
||||
return false;
|
||||
|
||||
if (!file.readValue(pp.rx()))
|
||||
return false;
|
||||
if (!file.readValue(pp.ry()))
|
||||
return false;
|
||||
if (!file.readValue(pz))
|
||||
return false;
|
||||
|
||||
ReferencePoint p;
|
||||
p.xy = xy.toPoint();
|
||||
p.pp = pp;
|
||||
points.append(p);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GeoTIFF::readMatrix(TIFFFile &file, quint32 offset, double matrix[16]) const
|
||||
{
|
||||
if (!file.seek(offset))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
if (!file.readValue(matrix[i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GeoTIFF::readKeys(TIFFFile &file, Ctx &ctx, QMap<quint16, Value> &kv) const
|
||||
{
|
||||
Header header;
|
||||
KeyEntry entry;
|
||||
Value value;
|
||||
|
||||
if (!file.seek(ctx.keys))
|
||||
return false;
|
||||
|
||||
if (!file.readValue(header.KeyDirectoryVersion))
|
||||
return false;
|
||||
if (!file.readValue(header.KeyRevision))
|
||||
return false;
|
||||
if (!file.readValue(header.MinorRevision))
|
||||
return false;
|
||||
if (!file.readValue(header.NumberOfKeys))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < header.NumberOfKeys; i++) {
|
||||
if (!file.readValue(entry.KeyID))
|
||||
return false;
|
||||
if (!file.readValue(entry.TIFFTagLocation))
|
||||
return false;
|
||||
if (!file.readValue(entry.Count))
|
||||
return false;
|
||||
if (!file.readValue(entry.ValueOffset))
|
||||
return false;
|
||||
|
||||
switch (entry.KeyID) {
|
||||
case GTModelTypeGeoKey:
|
||||
case GTRasterTypeGeoKey:
|
||||
case GeographicTypeGeoKey:
|
||||
case GeogGeodeticDatumGeoKey:
|
||||
case GeogPrimeMeridianGeoKey:
|
||||
case GeogAngularUnitsGeoKey:
|
||||
case ProjectedCSTypeGeoKey:
|
||||
case ProjectionGeoKey:
|
||||
case ProjCoordTransGeoKey:
|
||||
case ProjLinearUnitsGeoKey:
|
||||
if (entry.TIFFTagLocation != 0 || entry.Count != 1)
|
||||
return false;
|
||||
value.SHORT = entry.ValueOffset;
|
||||
kv.insert(entry.KeyID, value);
|
||||
break;
|
||||
case ProjScaleAtNatOriginGeoKey:
|
||||
case ProjNatOriginLongGeoKey:
|
||||
case ProjNatOriginLatGeoKey:
|
||||
case ProjFalseEastingGeoKey:
|
||||
case ProjFalseNorthingGeoKey:
|
||||
case ProjStdParallel1GeoKey:
|
||||
case ProjStdParallel2GeoKey:
|
||||
if (!readGeoValue(file, ctx.values, entry.ValueOffset,
|
||||
value.DOUBLE))
|
||||
return false;
|
||||
kv.insert(entry.KeyID, value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GeoTIFF::readGeoValue(TIFFFile &file, quint32 offset, quint16 index,
|
||||
double &val) const
|
||||
{
|
||||
qint64 pos = file.pos();
|
||||
|
||||
if (!file.seek(offset + index * sizeof(double)))
|
||||
return false;
|
||||
if (!file.readValue(val))
|
||||
return false;
|
||||
|
||||
if (!file.seek(pos))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const GCS *GeoTIFF::gcs(QMap<quint16, Value> &kv)
|
||||
{
|
||||
const GCS *gcs = 0;
|
||||
|
||||
if (IS_SET(kv, GeographicTypeGeoKey)) {
|
||||
if (!(gcs = GCS::gcs(kv.value(GeographicTypeGeoKey).SHORT)))
|
||||
_errorString = QString("%1: unknown GCS")
|
||||
.arg(kv.value(GeographicTypeGeoKey).SHORT);
|
||||
} else if (IS_SET(kv, GeogGeodeticDatumGeoKey)) {
|
||||
int pm = IS_SET(kv, GeogPrimeMeridianGeoKey)
|
||||
? kv.value(GeogPrimeMeridianGeoKey).SHORT : 8901;
|
||||
int au = IS_SET(kv, GeogAngularUnitsGeoKey)
|
||||
? kv.value(GeogAngularUnitsGeoKey).SHORT : 9102;
|
||||
|
||||
if (!(gcs = GCS::gcs(kv.value(GeogGeodeticDatumGeoKey).SHORT, pm, au)))
|
||||
_errorString = QString("%1+%2: unknown geodetic datum + prime"
|
||||
" meridian combination")
|
||||
.arg(kv.value(GeogGeodeticDatumGeoKey).SHORT)
|
||||
.arg(kv.value(GeogPrimeMeridianGeoKey).SHORT);
|
||||
} else
|
||||
_errorString = "Can not determine GCS";
|
||||
|
||||
return gcs;
|
||||
}
|
||||
|
||||
Projection::Method GeoTIFF::method(QMap<quint16, Value> &kv)
|
||||
{
|
||||
if (!IS_SET(kv, ProjCoordTransGeoKey)) {
|
||||
_errorString = "Missing coordinate transformation method";
|
||||
return Projection::Method();
|
||||
}
|
||||
|
||||
switch (kv.value(ProjCoordTransGeoKey).SHORT) {
|
||||
case 1:
|
||||
return Projection::Method(9807);
|
||||
case 7:
|
||||
return Projection::Method(1024);
|
||||
case 8:
|
||||
return Projection::Method(9801);
|
||||
case 9:
|
||||
return Projection::Method(9802);
|
||||
case 10:
|
||||
return Projection::Method(9820);
|
||||
case 11:
|
||||
return Projection::Method(9822);
|
||||
default:
|
||||
_errorString = QString("%1: unknown coordinate transformation method")
|
||||
.arg(kv.value(ProjCoordTransGeoKey).SHORT);
|
||||
return Projection::Method();
|
||||
}
|
||||
}
|
||||
|
||||
bool GeoTIFF::projectedModel(QMap<quint16, Value> &kv)
|
||||
{
|
||||
if (IS_SET(kv, ProjectedCSTypeGeoKey)) {
|
||||
const PCS *pcs;
|
||||
if (!(pcs = PCS::pcs(kv.value(ProjectedCSTypeGeoKey).SHORT))) {
|
||||
_errorString = QString("%1: unknown PCS")
|
||||
.arg(kv.value(ProjectedCSTypeGeoKey).SHORT);
|
||||
return false;
|
||||
}
|
||||
_projection = Projection(pcs->gcs(), pcs->method(), pcs->setup(),
|
||||
pcs->units());
|
||||
} else if (IS_SET(kv, ProjectionGeoKey)) {
|
||||
const GCS *g = gcs(kv);
|
||||
if (!g)
|
||||
return false;
|
||||
const PCS *pcs = PCS::pcs(g, kv.value(ProjectionGeoKey).SHORT);
|
||||
if (!pcs) {
|
||||
_errorString = QString("%1: unknown projection code")
|
||||
.arg(kv.value(GeographicTypeGeoKey).SHORT)
|
||||
.arg(kv.value(ProjectionGeoKey).SHORT);
|
||||
return false;
|
||||
}
|
||||
_projection = Projection(pcs->gcs(), pcs->method(), pcs->setup(),
|
||||
pcs->units());
|
||||
} else {
|
||||
const GCS *g = gcs(kv);
|
||||
if (!g)
|
||||
return false;
|
||||
Projection::Method m(method(kv));
|
||||
if (m.isNull())
|
||||
return false;
|
||||
|
||||
AngularUnits au(IS_SET(kv, GeogAngularUnitsGeoKey)
|
||||
? kv.value(GeogAngularUnitsGeoKey).SHORT : 9102);
|
||||
LinearUnits lu(IS_SET(kv, ProjLinearUnitsGeoKey)
|
||||
? kv.value(ProjLinearUnitsGeoKey).SHORT : 9001);
|
||||
if (lu.isNull()) {
|
||||
_errorString = QString("%1: unknown projection linear units code")
|
||||
.arg(kv.value(ProjLinearUnitsGeoKey).SHORT);
|
||||
return false;
|
||||
}
|
||||
|
||||
Projection::Setup setup(
|
||||
au.toDegrees(kv.value(ProjNatOriginLatGeoKey).DOUBLE),
|
||||
au.toDegrees(kv.value(ProjNatOriginLongGeoKey).DOUBLE),
|
||||
kv.value(ProjScaleAtNatOriginGeoKey).DOUBLE,
|
||||
lu.toMeters(kv.value(ProjFalseEastingGeoKey).DOUBLE),
|
||||
lu.toMeters(kv.value(ProjFalseNorthingGeoKey).DOUBLE),
|
||||
au.toDegrees(kv.value(ProjStdParallel1GeoKey).DOUBLE),
|
||||
au.toDegrees(kv.value(ProjStdParallel2GeoKey).DOUBLE)
|
||||
);
|
||||
|
||||
_projection = Projection(g, m, setup, lu);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GeoTIFF::geographicModel(QMap<quint16, Value> &kv)
|
||||
{
|
||||
const GCS *g = gcs(kv);
|
||||
if (!g)
|
||||
return false;
|
||||
|
||||
_projection = Projection(g);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GeoTIFF::load(const QString &path)
|
||||
{
|
||||
quint32 ifd;
|
||||
QList<ReferencePoint> points;
|
||||
QPointF scale;
|
||||
QMap<quint16, Value> kv;
|
||||
Ctx ctx;
|
||||
TIFFFile file;
|
||||
|
||||
|
||||
file.setFileName(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
_errorString = QString("Error opening TIFF file: %1")
|
||||
.arg(file.errorString());
|
||||
return false;
|
||||
}
|
||||
if (!file.readHeader(ifd)) {
|
||||
_errorString = "Invalid TIFF header";
|
||||
return false;
|
||||
}
|
||||
|
||||
while (ifd) {
|
||||
if (!readIFD(file, ifd, ctx)) {
|
||||
_errorString = "Invalid IFD";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ctx.keys) {
|
||||
_errorString = "Not a GeoTIFF file";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ctx.scale) {
|
||||
if (!readScale(file, ctx.scale, scale)) {
|
||||
_errorString = "Error reading model pixel scale";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (ctx.tiepoints) {
|
||||
if (!readTiepoints(file, ctx.tiepoints, ctx.tiepointCount, points)) {
|
||||
_errorString = "Error reading raster->model tiepoint pairs";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!readKeys(file, ctx, kv)) {
|
||||
_errorString = "Error reading Geo key/value";
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (kv.value(GTModelTypeGeoKey).SHORT) {
|
||||
case ModelTypeProjected:
|
||||
if (!projectedModel(kv))
|
||||
return false;
|
||||
break;
|
||||
case ModelTypeGeographic:
|
||||
if (!geographicModel(kv))
|
||||
return false;
|
||||
break;
|
||||
case ModelTypeGeocentric:
|
||||
_errorString = "Geocentric models are not supported";
|
||||
return false;
|
||||
default:
|
||||
_errorString = "Unknown/missing model type";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ctx.scale && ctx.tiepoints) {
|
||||
const ReferencePoint &p = points.first();
|
||||
_transform = QTransform(scale.x(), 0, 0, -scale.y(), p.pp.x() - p.xy.x()
|
||||
/ scale.x(), p.pp.y() + p.xy.x() / scale.y()).inverted();
|
||||
} else if (ctx.tiepointCount > 1) {
|
||||
Transform t(points);
|
||||
if (t.isNull()) {
|
||||
_errorString = t.errorString();
|
||||
return false;
|
||||
}
|
||||
_transform = t.transform();
|
||||
} else if (ctx.matrix) {
|
||||
double m[16];
|
||||
if (!readMatrix(file, ctx.matrix, m)) {
|
||||
_errorString = "Error reading transformation matrix";
|
||||
return false;
|
||||
}
|
||||
if (m[2] != 0.0 || m[6] != 0.0 || m[8] != 0.0 || m[9] != 0.0
|
||||
|| m[10] != 0.0 || m[11] != 0.0) {
|
||||
_errorString = "Not a baseline transformation matrix";
|
||||
}
|
||||
_transform = QTransform(m[0], m[1], m[4], m[5], m[3], m[7]).inverted();
|
||||
} else {
|
||||
_errorString = "Incomplete/missing model transformation info";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
61
src/map/geotiff.h
Normal file
61
src/map/geotiff.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef GEOTIFF_H
|
||||
#define GEOTIFF_H
|
||||
|
||||
#include <QTransform>
|
||||
#include <QFile>
|
||||
#include <QMap>
|
||||
#include "gcs.h"
|
||||
#include "projection.h"
|
||||
#include "tifffile.h"
|
||||
#include "transform.h"
|
||||
#include "linearunits.h"
|
||||
|
||||
class GeoTIFF
|
||||
{
|
||||
public:
|
||||
bool load(const QString &path);
|
||||
const QString &errorString() const {return _errorString;}
|
||||
|
||||
const Projection &projection() const {return _projection;}
|
||||
const QTransform &transform() const {return _transform;}
|
||||
|
||||
private:
|
||||
union Value {
|
||||
quint16 SHORT;
|
||||
double DOUBLE;
|
||||
};
|
||||
|
||||
struct Ctx {
|
||||
quint32 scale;
|
||||
quint32 tiepoints;
|
||||
quint32 tiepointCount;
|
||||
quint32 matrix;
|
||||
quint32 keys;
|
||||
quint32 values;
|
||||
|
||||
Ctx() : scale(0), tiepoints(0), tiepointCount(0), matrix(0), keys(0),
|
||||
values(0) {}
|
||||
};
|
||||
|
||||
bool readEntry(TIFFFile &file, Ctx &ctx) const;
|
||||
bool readIFD(TIFFFile &file, quint32 &offset, Ctx &ctx) const;
|
||||
bool readScale(TIFFFile &file, quint32 offset, QPointF &scale) const;
|
||||
bool readTiepoints(TIFFFile &file, quint32 offset, quint32 count,
|
||||
QList<ReferencePoint> &points) const;
|
||||
bool readMatrix(TIFFFile &file, quint32 offset, double matrix[16]) const;
|
||||
bool readKeys(TIFFFile &file, Ctx &ctx, QMap<quint16, Value> &kv) const;
|
||||
bool readGeoValue(TIFFFile &file, quint32 offset, quint16 index,
|
||||
double &val) const;
|
||||
|
||||
const GCS *gcs(QMap<quint16, Value> &kv);
|
||||
Projection::Method method(QMap<quint16, Value> &kv);
|
||||
bool geographicModel(QMap<quint16, Value> &kv);
|
||||
bool projectedModel(QMap<quint16, Value> &kv);
|
||||
|
||||
QTransform _transform;
|
||||
Projection _projection;
|
||||
|
||||
QString _errorString;
|
||||
};
|
||||
|
||||
#endif // GEOTIFF_H
|
@ -48,19 +48,19 @@ Defense.
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#endif // M_PI_2
|
||||
|
||||
LambertAzimuthal::LambertAzimuthal(const Ellipsoid &ellipsoid,
|
||||
LambertAzimuthal::LambertAzimuthal(const Ellipsoid *ellipsoid,
|
||||
double latitudeOrigin, double longitudeOrigin, double falseEasting,
|
||||
double falseNorthing)
|
||||
{
|
||||
double es2, es4, es6;
|
||||
|
||||
_e = ellipsoid;
|
||||
es2 = 2 * _e.flattening() - _e.flattening() * _e.flattening();
|
||||
es2 = 2 * ellipsoid->flattening() - ellipsoid->flattening()
|
||||
* ellipsoid->flattening();
|
||||
|
||||
es4 = es2 * es2;
|
||||
es6 = es4 * es2;
|
||||
_ra = _e.radius() * (1.0 - es2 / 6.0 - 17.0 * es4 / 360.0 - 67.0 * es6
|
||||
/ 3024.0);
|
||||
_ra = ellipsoid->radius() * (1.0 - es2 / 6.0 - 17.0 * es4 / 360.0 - 67.0
|
||||
* es6 / 3024.0);
|
||||
_latOrigin = deg2rad(latitudeOrigin);
|
||||
_sinLatOrigin = sin(_latOrigin);
|
||||
_cosLatOrigin = cos(_latOrigin);
|
||||
|
@ -2,20 +2,20 @@
|
||||
#define LAMBERTAZIMUTHAL_H
|
||||
|
||||
#include "ellipsoid.h"
|
||||
#include "projection.h"
|
||||
#include "ct.h"
|
||||
|
||||
class LambertAzimuthal : public Projection
|
||||
class LambertAzimuthal : public CT
|
||||
{
|
||||
public:
|
||||
LambertAzimuthal(const Ellipsoid &ellipsoid, double latitudeOrigin,
|
||||
LambertAzimuthal(const Ellipsoid *ellipsoid, double latitudeOrigin,
|
||||
double longitudeOrigin, double falseEasting, double falseNorthing);
|
||||
|
||||
virtual CT *clone() const {return new LambertAzimuthal(*this);}
|
||||
|
||||
virtual QPointF ll2xy(const Coordinates &c) const;
|
||||
virtual Coordinates xy2ll(const QPointF &p) const;
|
||||
|
||||
private:
|
||||
Ellipsoid _e;
|
||||
|
||||
double _ra;
|
||||
double _sinLatOrigin;
|
||||
double _cosLatOrigin;
|
||||
|
@ -1,3 +1,46 @@
|
||||
/*
|
||||
* 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 <cmath>
|
||||
#include "lambertconic.h"
|
||||
|
||||
@ -5,76 +48,229 @@
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#endif // M_PI_2
|
||||
#ifndef M_PI_4
|
||||
#define M_PI_4 0.78539816339744830962
|
||||
#endif // M_PI_4
|
||||
#define M_PI_4 0.785398163397448309616
|
||||
#endif /* M_PI_4 */
|
||||
|
||||
static double q(const Ellipsoid &el, double b)
|
||||
#define LAMBERT_m(clat, essin) (clat / sqrt(1.0 - essin * essin))
|
||||
#define LAMBERT2_t(lat, essin, es_over_2) \
|
||||
(tan(M_PI_4 - lat / 2) * pow((1.0 + essin) / (1.0 - essin), es_over_2))
|
||||
#define LAMBERT1_t(lat, essin, es_over_2) \
|
||||
(tan(M_PI_4 - lat / 2) / pow((1.0 - essin) / (1.0 + essin), es_over_2))
|
||||
|
||||
|
||||
LambertConic1::LambertConic1(const Ellipsoid *ellipsoid, double latitudeOrigin,
|
||||
double longitudeOrigin, double scale, double falseEasting,
|
||||
double falseNorthing)
|
||||
{
|
||||
double e = sqrt(el.flattening() * (2. - el.flattening()));
|
||||
double esb = e * sin(b);
|
||||
return log(tan(M_PI_4 + b / 2.) * pow((1. - esb) / (1. + esb), e / 2.));
|
||||
double es2;
|
||||
double es_sin;
|
||||
double m0;
|
||||
double lat_orig;
|
||||
|
||||
|
||||
lat_orig = deg2rad(latitudeOrigin);
|
||||
_longitudeOrigin = deg2rad(longitudeOrigin);
|
||||
if (_longitudeOrigin > M_PI)
|
||||
_longitudeOrigin -= 2 * M_PI;
|
||||
|
||||
_falseEasting = falseEasting;
|
||||
_falseNorthing = falseNorthing;
|
||||
|
||||
es2 = 2.0 * ellipsoid->flattening() - ellipsoid->flattening()
|
||||
* ellipsoid->flattening();
|
||||
_es = sqrt(es2);
|
||||
_es_over_2 = _es / 2.0;
|
||||
|
||||
_n = sin(lat_orig);
|
||||
|
||||
es_sin = _es * sin(lat_orig);
|
||||
m0 = LAMBERT_m(cos(lat_orig), es_sin);
|
||||
_t0 = LAMBERT1_t(lat_orig, es_sin, _es_over_2);
|
||||
|
||||
_rho0 = ellipsoid->radius() * scale * m0 / _n;
|
||||
|
||||
_rho_olat = _rho0;
|
||||
}
|
||||
|
||||
static double iq(const Ellipsoid &el, double q)
|
||||
QPointF LambertConic1::ll2xy(const Coordinates &c) const
|
||||
{
|
||||
double e = sqrt(el.flattening() * (2. - el.flattening()));
|
||||
double b0 = 0.;
|
||||
double b = 2. * atan(exp(q)) - M_PI_2;
|
||||
double t;
|
||||
double rho;
|
||||
double dlam;
|
||||
double theta;
|
||||
double lat = deg2rad(c.lat());
|
||||
|
||||
do {
|
||||
b0 = b;
|
||||
double esb = e * sin(b);
|
||||
b = 2. * atan(exp(q) * pow((1. - esb) / (1. + esb), -e / 2.)) - M_PI_2;
|
||||
} while (fabs(b - b0) > 1e-10);
|
||||
|
||||
return b;
|
||||
if (fabs(fabs(lat) - M_PI_2) > 1.0e-10) {
|
||||
t = LAMBERT1_t(lat, _es * sin(lat), _es_over_2);
|
||||
rho = _rho0 * pow(t / _t0, _n);
|
||||
} else
|
||||
rho = 0.0;
|
||||
|
||||
dlam = deg2rad(c.lon()) - _longitudeOrigin;
|
||||
|
||||
if (dlam > M_PI)
|
||||
dlam -= 2 * M_PI;
|
||||
if (dlam < -M_PI)
|
||||
dlam += 2 * M_PI;
|
||||
|
||||
theta = _n * dlam;
|
||||
|
||||
return QPointF(rho * sin(theta) + _falseEasting, _rho_olat - rho
|
||||
* cos(theta) + _falseNorthing);
|
||||
}
|
||||
|
||||
static double nradius(const Ellipsoid &el, double phi)
|
||||
Coordinates LambertConic1::xy2ll(const QPointF &p) const
|
||||
{
|
||||
double sin_phi = sin(phi);
|
||||
return (el.radius() / sqrt(1. - (el.flattening() * (2. - el.flattening()))
|
||||
* sin_phi * sin_phi));
|
||||
double dx;
|
||||
double dy;
|
||||
double rho;
|
||||
double rho_olat_minus_dy;
|
||||
double t;
|
||||
double PHI;
|
||||
double es_sin;
|
||||
double tempPHI = 0.0;
|
||||
double theta = 0.0;
|
||||
double tolerance = 4.85e-10;
|
||||
int count = 30;
|
||||
double lat, lon;
|
||||
|
||||
|
||||
dy = p.y() - _falseNorthing;
|
||||
dx = p.x() - _falseEasting;
|
||||
rho_olat_minus_dy = _rho_olat - dy;
|
||||
rho = sqrt(dx * dx + (rho_olat_minus_dy) * (rho_olat_minus_dy));
|
||||
|
||||
if (_n < 0.0) {
|
||||
rho *= -1.0;
|
||||
dx *= -1.0;
|
||||
rho_olat_minus_dy *= -1.0;
|
||||
}
|
||||
|
||||
if (rho != 0.0) {
|
||||
theta = atan2(dx, rho_olat_minus_dy) / _n;
|
||||
t = _t0 * pow(rho / _rho0, 1 / _n);
|
||||
PHI = M_PI_2 - 2.0 * atan(t);
|
||||
while (fabs(PHI - tempPHI) > tolerance && count) {
|
||||
tempPHI = PHI;
|
||||
es_sin = _es * sin(PHI);
|
||||
PHI = M_PI_2 - 2.0 * atan(t * pow((1.0 - es_sin) / (1.0 + es_sin),
|
||||
_es_over_2));
|
||||
count--;
|
||||
}
|
||||
|
||||
if (!count)
|
||||
return Coordinates();
|
||||
|
||||
lat = PHI;
|
||||
lon = theta + _longitudeOrigin;
|
||||
|
||||
if (fabs(lat) < 2.0e-7)
|
||||
lat = 0.0;
|
||||
if (lat > M_PI_2)
|
||||
lat = M_PI_2;
|
||||
else if (lat < -M_PI_2)
|
||||
lat = -M_PI_2;
|
||||
|
||||
if (lon > M_PI) {
|
||||
if (lon - M_PI < 3.5e-6)
|
||||
lon = M_PI;
|
||||
else
|
||||
lon -= 2 * M_PI;
|
||||
}
|
||||
if (lon < -M_PI) {
|
||||
if (fabs(lon + M_PI) < 3.5e-6)
|
||||
lon = -M_PI;
|
||||
else
|
||||
lon += 2 * M_PI;
|
||||
}
|
||||
|
||||
if (fabs(lon) < 2.0e-7)
|
||||
lon = 0.0;
|
||||
if (lon > M_PI)
|
||||
lon = M_PI;
|
||||
else if (lon < -M_PI)
|
||||
lon = -M_PI;
|
||||
} else {
|
||||
if (_n > 0.0)
|
||||
lat = M_PI_2;
|
||||
else
|
||||
lat = -M_PI_2;
|
||||
lon = _longitudeOrigin;
|
||||
}
|
||||
|
||||
return Coordinates(rad2deg(lon), rad2deg(lat));
|
||||
}
|
||||
|
||||
LambertConic::LambertConic(const Ellipsoid &ellipsoid, double standardParallel1,
|
||||
double standardParallel2, double latitudeOrigin, double longitudeOrigin,
|
||||
double scale, double falseEasting, double falseNorthing) : _e(ellipsoid)
|
||||
LambertConic2::LambertConic2(const Ellipsoid *ellipsoid,
|
||||
double standardParallel1, double standardParallel2, double latitudeOrigin,
|
||||
double longitudeOrigin, double falseEasting, double falseNorthing)
|
||||
{
|
||||
_cm = deg2rad(longitudeOrigin);
|
||||
_fe = falseEasting;
|
||||
_fn = falseNorthing;
|
||||
double es, es_over_2, es2, es_sin;
|
||||
double lat0;
|
||||
double k0;
|
||||
double t0;
|
||||
double t1, t2;
|
||||
double t_olat;
|
||||
double m0;
|
||||
double m1;
|
||||
double m2;
|
||||
double n;
|
||||
double const_value;
|
||||
double sp1, sp2;
|
||||
double lat_orig;
|
||||
|
||||
double sp1 = deg2rad(standardParallel1);
|
||||
double sp2 = deg2rad(standardParallel2);
|
||||
|
||||
double N1 = nradius(_e, sp1);
|
||||
double N2 = nradius(_e, sp2);
|
||||
lat_orig = deg2rad(latitudeOrigin);
|
||||
sp1 = deg2rad(standardParallel1);
|
||||
sp2 = deg2rad(standardParallel2);
|
||||
|
||||
_q0 = q(_e, deg2rad(latitudeOrigin));
|
||||
double q1 = q(_e, sp1);
|
||||
double q2 = q(_e, sp2);
|
||||
if (fabs(sp1 - sp2) > 1.0e-10) {
|
||||
es2 = 2 * ellipsoid->flattening() - ellipsoid->flattening()
|
||||
* ellipsoid->flattening();
|
||||
es = sqrt(es2);
|
||||
es_over_2 = es / 2.0;
|
||||
|
||||
_n = log((N1 * cos(sp1)) / (N2 * cos(sp2))) / (q2 - q1);
|
||||
double R1 = N1 * cos(sp1) / _n;
|
||||
_R0 = scale * R1 * exp(_n * (q1 - _q0));
|
||||
es_sin = es * sin(lat_orig);
|
||||
t_olat = LAMBERT2_t(lat_orig, es_sin, es_over_2);
|
||||
|
||||
es_sin = es * sin(sp1);
|
||||
m1 = LAMBERT_m(cos(sp1), es_sin);
|
||||
t1 = LAMBERT2_t(sp1, es_sin, es_over_2);
|
||||
|
||||
es_sin = es * sin(sp2);
|
||||
m2 = LAMBERT_m(cos(sp2), es_sin);
|
||||
t2 = LAMBERT2_t(sp2, es_sin, es_over_2);
|
||||
|
||||
n = log(m1 / m2) / log(t1 / t2);
|
||||
|
||||
lat0 = asin(n);
|
||||
|
||||
es_sin = es * sin(lat0);
|
||||
m0 = LAMBERT_m(cos(lat0), es_sin);
|
||||
t0 = LAMBERT2_t(lat0, es_sin, es_over_2);
|
||||
|
||||
k0 = (m1 / m0) * (pow(t0 / t1, n));
|
||||
|
||||
const_value = ((ellipsoid->radius() * m2) / (n * pow(t2, n)));
|
||||
|
||||
falseNorthing += (const_value * pow(t_olat, n)) - (const_value
|
||||
* pow(t0, n));
|
||||
} else {
|
||||
lat0 = sp1;
|
||||
k0 = 1.0;
|
||||
}
|
||||
|
||||
_lc1 = LambertConic1(ellipsoid, rad2deg(lat0), longitudeOrigin, k0,
|
||||
falseEasting, falseNorthing);
|
||||
}
|
||||
|
||||
QPointF LambertConic::ll2xy(const Coordinates &c) const
|
||||
QPointF LambertConic2::ll2xy(const Coordinates &c) const
|
||||
{
|
||||
double dl = _n * (deg2rad(c.lon()) - _cm);
|
||||
double R = _R0 * exp(_n * (_q0 - q(_e, deg2rad(c.lat()))));
|
||||
|
||||
return QPointF(_fe + R * sin(dl), _fn + _R0 - R * cos(dl));
|
||||
return _lc1.ll2xy(c);
|
||||
}
|
||||
|
||||
Coordinates LambertConic::xy2ll(const QPointF &p) const
|
||||
Coordinates LambertConic2::xy2ll(const QPointF &p) const
|
||||
{
|
||||
double dl = atan((p.x() - _fe) / (_fn + _R0 - p.y()));
|
||||
double dx = p.x() - _fe;
|
||||
double dy = p.y() - _fn - _R0;
|
||||
double R = sqrt(dx * dx + dy * dy);
|
||||
double q = _q0 - log(fabs(R / _R0)) / _n;
|
||||
|
||||
return Coordinates(rad2deg(_cm + dl / _n), rad2deg(iq(_e, q)));
|
||||
return _lc1.xy2ll(p);
|
||||
}
|
||||
|
@ -2,28 +2,48 @@
|
||||
#define LAMBERTCONIC_H
|
||||
|
||||
#include "ellipsoid.h"
|
||||
#include "projection.h"
|
||||
#include "ct.h"
|
||||
|
||||
class LambertConic : public Projection
|
||||
class LambertConic1 : public CT
|
||||
{
|
||||
public:
|
||||
LambertConic(const Ellipsoid &ellipsoid, double standardParallel1,
|
||||
double standardParallel2, double latitudeOrigin, double longitudeOrigin,
|
||||
double scale, double falseEasting, double falseNorthing);
|
||||
LambertConic1() {}
|
||||
LambertConic1(const Ellipsoid *ellipsoid, double latitudeOrigin,
|
||||
double longitudeOrigin, double scale, double falseEasting,
|
||||
double falseNorthing);
|
||||
|
||||
virtual CT *clone() const {return new LambertConic1(*this);}
|
||||
|
||||
virtual QPointF ll2xy(const Coordinates &c) const;
|
||||
virtual Coordinates xy2ll(const QPointF &p) const;
|
||||
|
||||
private:
|
||||
Ellipsoid _e;
|
||||
double _longitudeOrigin;
|
||||
double _falseEasting;
|
||||
double _falseNorthing;
|
||||
|
||||
double _cm;
|
||||
double _fe;
|
||||
double _fn;
|
||||
|
||||
double _q0;
|
||||
double _R0;
|
||||
double _es;
|
||||
double _es_over_2;
|
||||
double _n;
|
||||
double _t0;
|
||||
double _rho0;
|
||||
double _rho_olat;
|
||||
};
|
||||
|
||||
class LambertConic2 : public CT
|
||||
{
|
||||
public:
|
||||
LambertConic2(const Ellipsoid *ellipsoid, double standardParallel1,
|
||||
double standardParallel2, double latitudeOrigin, double longitudeOrigin,
|
||||
double falseEasting, double falseNorthing);
|
||||
|
||||
virtual CT *clone() const {return new LambertConic2(*this);}
|
||||
|
||||
virtual QPointF ll2xy(const Coordinates &c) const;
|
||||
virtual Coordinates xy2ll(const QPointF &p) const;
|
||||
|
||||
private:
|
||||
LambertConic1 _lc1;
|
||||
};
|
||||
|
||||
#endif // LAMBERTCONIC_H
|
||||
|
@ -1,15 +1,23 @@
|
||||
#ifndef LATLON_H
|
||||
#define LATLON_H
|
||||
|
||||
#include "projection.h"
|
||||
#include "ct.h"
|
||||
#include "angularunits.h"
|
||||
|
||||
class LatLon : public Projection
|
||||
class LatLon : public CT
|
||||
{
|
||||
public:
|
||||
LatLon(const AngularUnits &au) : _au(au) {}
|
||||
|
||||
virtual CT *clone() const {return new LatLon(*this);}
|
||||
|
||||
virtual QPointF ll2xy(const Coordinates &c) const
|
||||
{return QPointF(c.lon(), c.lat());}
|
||||
{return QPointF(_au.fromDegrees(c.lon()), _au.fromDegrees(c.lat()));}
|
||||
virtual Coordinates xy2ll(const QPointF &p) const
|
||||
{return Coordinates(p.x(), p.y());}
|
||||
{return Coordinates(_au.toDegrees(p.x()), _au.toDegrees(p.y()));}
|
||||
|
||||
private:
|
||||
AngularUnits _au;
|
||||
};
|
||||
|
||||
#endif // LATLON_H
|
||||
|
27
src/map/linearunits.cpp
Normal file
27
src/map/linearunits.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "linearunits.h"
|
||||
|
||||
LinearUnits::LinearUnits(int code)
|
||||
{
|
||||
switch (code) {
|
||||
case 9001:
|
||||
_f = 1.0;
|
||||
break;
|
||||
case 9002:
|
||||
_f = 0.3048;
|
||||
break;
|
||||
case 9003:
|
||||
_f = 12.0 / 39.37;
|
||||
break;
|
||||
case 9040:
|
||||
_f = 36.0 / 39.370147;
|
||||
break;
|
||||
default:
|
||||
_f = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const LinearUnits &lu)
|
||||
{
|
||||
dbg.nospace() << "LinearUnits(" << lu._f << ")";
|
||||
return dbg.space();
|
||||
}
|
36
src/map/linearunits.h
Normal file
36
src/map/linearunits.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef LINEARUNITS_H
|
||||
#define LINEARUNITS_H
|
||||
|
||||
#include <cmath>
|
||||
#include <QDebug>
|
||||
#include <QPointF>
|
||||
|
||||
class LinearUnits
|
||||
{
|
||||
public:
|
||||
LinearUnits() : _f(NAN) {}
|
||||
LinearUnits(int code);
|
||||
|
||||
bool isNull() const {return std::isnan(_f);}
|
||||
bool isValid() const {return !std::isnan(_f);}
|
||||
|
||||
double toMeters(double val) const {return val * _f;}
|
||||
QPointF toMeters(const QPointF &p) const
|
||||
{return QPointF(p.x() * _f, p.y() * _f);}
|
||||
double fromMeters(double val) const {return val / _f;}
|
||||
QPointF fromMeters(const QPointF &p) const
|
||||
{return QPointF(p.x() / _f, p.y() /_f);}
|
||||
|
||||
friend bool operator==(const LinearUnits &lu1, const LinearUnits &lu2);
|
||||
friend QDebug operator<<(QDebug dbg, const LinearUnits &lu);
|
||||
|
||||
private:
|
||||
double _f;
|
||||
};
|
||||
|
||||
inline bool operator==(const LinearUnits &lu1, const LinearUnits &lu2)
|
||||
{return (lu1._f == lu2._f);}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const LinearUnits &lu);
|
||||
|
||||
#endif // LINEARUNITS_H
|
265
src/map/mapfile.cpp
Normal file
265
src/map/mapfile.cpp
Normal file
@ -0,0 +1,265 @@
|
||||
#include "utm.h"
|
||||
#include "gcs.h"
|
||||
#include "mapfile.h"
|
||||
|
||||
|
||||
static double parameter(const QString &str, bool *res)
|
||||
{
|
||||
QString field = str.trimmed();
|
||||
if (field.isEmpty()) {
|
||||
*res = true;
|
||||
return NAN;
|
||||
}
|
||||
|
||||
return field.toDouble(res);
|
||||
}
|
||||
|
||||
int MapFile::parse(QIODevice &device, QList<CalibrationPoint> &points,
|
||||
QString &projection, Projection::Setup &setup, QString &datum)
|
||||
{
|
||||
bool res, r[8];
|
||||
int ln = 1;
|
||||
|
||||
while (!device.atEnd()) {
|
||||
QByteArray line = device.readLine();
|
||||
|
||||
if (ln == 1) {
|
||||
if (!line.trimmed().startsWith("OziExplorer Map Data File"))
|
||||
return ln;
|
||||
} else if (ln == 2)
|
||||
_name = line.trimmed();
|
||||
else if (ln == 3)
|
||||
_image = line.trimmed();
|
||||
else if (ln == 5)
|
||||
datum = line.split(',').at(0).trimmed();
|
||||
else {
|
||||
QList<QByteArray> list = line.split(',');
|
||||
QString key(list.at(0).trimmed());
|
||||
bool ll = true; bool pp = true;
|
||||
|
||||
|
||||
if (key.startsWith("Point") && list.count() == 17
|
||||
&& !list.at(2).trimmed().isEmpty()) {
|
||||
CalibrationPoint p;
|
||||
|
||||
int x = list.at(2).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
return ln;
|
||||
int y = list.at(3).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
return ln;
|
||||
|
||||
int latd = list.at(6).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
qreal latm = list.at(7).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
int lond = list.at(9).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
qreal lonm = list.at(10).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
if (ll && list.at(8).trimmed() == "S") {
|
||||
latd = -latd;
|
||||
latm = -latm;
|
||||
}
|
||||
if (ll && list.at(11).trimmed() == "W") {
|
||||
lond = -lond;
|
||||
lonm = -lonm;
|
||||
}
|
||||
|
||||
p.zone = list.at(13).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
p.zone = 0;
|
||||
qreal ppx = list.at(14).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
pp = false;
|
||||
qreal ppy = list.at(15).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
pp = false;
|
||||
if (list.at(16).trimmed() == "S")
|
||||
p.zone = -p.zone;
|
||||
|
||||
p.rp.xy = QPoint(x, y);
|
||||
if (ll) {
|
||||
p.ll = Coordinates(lond + lonm/60.0, latd + latm/60.0);
|
||||
if (p.ll.isValid())
|
||||
points.append(p);
|
||||
else
|
||||
return ln;
|
||||
} else if (pp) {
|
||||
p.rp.pp = QPointF(ppx, ppy);
|
||||
points.append(p);
|
||||
} else
|
||||
return ln;
|
||||
} else if (key == "IWH") {
|
||||
if (list.count() < 4)
|
||||
return ln;
|
||||
int w = list.at(2).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
return ln;
|
||||
int h = list.at(3).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
return ln;
|
||||
_size = QSize(w, h);
|
||||
} else if (key == "Map Projection") {
|
||||
if (list.count() < 2)
|
||||
return ln;
|
||||
projection = list.at(1);
|
||||
} else if (key == "Projection Setup") {
|
||||
if (list.count() < 8)
|
||||
return ln;
|
||||
|
||||
setup = Projection::Setup(
|
||||
parameter(list[1], &r[1]), parameter(list[2], &r[2]),
|
||||
parameter(list[3], &r[3]), parameter(list[4], &r[4]),
|
||||
parameter(list[5], &r[5]), parameter(list[6], &r[6]),
|
||||
parameter(list[7], &r[7]));
|
||||
|
||||
for (int i = 1; i < 8; i++)
|
||||
if (!r[i])
|
||||
return ln;
|
||||
}
|
||||
}
|
||||
|
||||
ln++;
|
||||
}
|
||||
|
||||
return (ln == 1) ? 1 : 0;
|
||||
}
|
||||
|
||||
bool MapFile::parseMapFile(QIODevice &device, QList<CalibrationPoint> &points,
|
||||
QString &projection, Projection::Setup &setup, QString &datum)
|
||||
{
|
||||
int el;
|
||||
|
||||
if (!device.open(QIODevice::ReadOnly)) {
|
||||
_errorString = QString("Error opening file: %1")
|
||||
.arg(device.errorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((el = parse(device, points, projection, setup, datum))) {
|
||||
_errorString = QString("Parse error on line %1").arg(el);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const GCS *MapFile::createGCS(const QString &datum)
|
||||
{
|
||||
const GCS *gcs;
|
||||
|
||||
if (!(gcs = GCS::gcs(datum)))
|
||||
_errorString = QString("%1: Unknown datum").arg(datum);
|
||||
|
||||
return gcs;
|
||||
}
|
||||
|
||||
bool MapFile::createProjection(const GCS *gcs, const QString &name,
|
||||
const Projection::Setup &setup, QList<CalibrationPoint> &points)
|
||||
{
|
||||
if (name == "Mercator")
|
||||
_projection = Projection(gcs, 1024, setup, 9001);
|
||||
else if (name == "Transverse Mercator")
|
||||
_projection = Projection(gcs, 9807, setup, 9001);
|
||||
else if (name == "Latitude/Longitude")
|
||||
_projection = Projection(gcs);
|
||||
else if (name == "Lambert Conformal Conic")
|
||||
_projection = Projection(gcs, 9802, setup, 9001);
|
||||
else if (name == "Albers Equal Area")
|
||||
_projection = Projection(gcs, 9822, setup, 9001);
|
||||
else if (name == "(A)Lambert Azimuthual Equal Area")
|
||||
_projection = Projection(gcs, 9820, setup, 9001);
|
||||
else if (name == "(UTM) Universal Transverse Mercator") {
|
||||
int zone;
|
||||
if (points.first().zone)
|
||||
zone = points.first().zone;
|
||||
else if (!points.first().ll.isNull())
|
||||
zone = UTM::zone(points.first().ll);
|
||||
else {
|
||||
_errorString = "Can not determine UTM zone";
|
||||
return false;
|
||||
}
|
||||
_projection = Projection(gcs, 9807, UTM::setup(zone), 9001);
|
||||
} else if (name == "(NZTM2) New Zealand TM 2000")
|
||||
_projection = Projection(gcs, 9807, Projection::Setup(0, 173.0, 0.9996,
|
||||
1600000, 10000000, NAN, NAN), 9001);
|
||||
else if (name == "(BNG) British National Grid")
|
||||
_projection = Projection(gcs, 9807, Projection::Setup(49, -2, 0.999601,
|
||||
400000, -100000, NAN, NAN), 9001);
|
||||
else if (name == "(IG) Irish Grid")
|
||||
_projection = Projection(gcs, 9807, Projection::Setup(53.5, -8,
|
||||
1.000035, 200000, 250000, NAN, NAN), 9001);
|
||||
else if (name == "(SG) Swedish Grid")
|
||||
_projection = Projection(gcs, 9807, Projection::Setup(0, 15.808278, 1,
|
||||
1500000, 0, NAN, NAN), 9001);
|
||||
else if (name == "(I) France Zone I")
|
||||
_projection = Projection(gcs, 9802, Projection::Setup(49.5, 2.337229,
|
||||
NAN, 600000, 1200000, 48.598523, 50.395912), 9001);
|
||||
else if (name == "(II) France Zone II")
|
||||
_projection = Projection(gcs, 9802, Projection::Setup(46.8, 2.337229,
|
||||
NAN, 600000, 2200000, 45.898919, 47.696014), 9001);
|
||||
else if (name == "(III) France Zone III")
|
||||
_projection = Projection(gcs, 9802, Projection::Setup(44.1, 2.337229,
|
||||
NAN, 600000, 3200000, 43.199291, 44.996094), 9001);
|
||||
else if (name == "(IV) France Zone IV")
|
||||
_projection = Projection(gcs, 9802, Projection::Setup(42.165, 2.337229,
|
||||
NAN, 234.358, 4185861.369, 41.560388, 42.767663), 9001);
|
||||
else if (name == "(VICGRID) Victoria Australia")
|
||||
_projection = Projection(gcs, 9802, Projection::Setup(-37, 145, NAN,
|
||||
2500000, 4500000, -36, -38), 9001);
|
||||
else if (name == "(VG94) VICGRID94 Victoria Australia")
|
||||
_projection = Projection(gcs, 9802, Projection::Setup(-37, 145, NAN,
|
||||
2500000, 2500000, -36, -38), 9001);
|
||||
else {
|
||||
_errorString = QString("%1: Unknown map projection").arg(name);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MapFile::computeTransformation(QList<CalibrationPoint> &points)
|
||||
{
|
||||
QList<ReferencePoint> rp;
|
||||
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
if (points.at(i).rp.pp.isNull())
|
||||
points[i].rp.pp = _projection.ll2xy(points.at(i).ll);
|
||||
|
||||
rp.append(points.at(i).rp);
|
||||
}
|
||||
|
||||
Transform t(rp);
|
||||
if (t.isNull()) {
|
||||
_errorString = t.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
_transform = t.transform();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MapFile::load(QIODevice &file)
|
||||
{
|
||||
QList<CalibrationPoint> points;
|
||||
QString ct, datum;
|
||||
Projection::Setup setup;
|
||||
const GCS *gcs;
|
||||
|
||||
if (!parseMapFile(file, points, ct, setup, datum))
|
||||
return false;
|
||||
if (!(gcs = createGCS(datum)))
|
||||
return false;
|
||||
if (!createProjection(gcs, ct, setup, points))
|
||||
return false;
|
||||
if (!computeTransformation(points))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
49
src/map/mapfile.h
Normal file
49
src/map/mapfile.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef MAPFILE_H
|
||||
#define MAPFILE_H
|
||||
|
||||
#include <QIODevice>
|
||||
#include <QTransform>
|
||||
#include "gcs.h"
|
||||
#include "transform.h"
|
||||
#include "projection.h"
|
||||
|
||||
class MapFile
|
||||
{
|
||||
public:
|
||||
bool load(QIODevice &file);
|
||||
const QString &errorString() const {return _errorString;}
|
||||
|
||||
const Projection &projection() const {return _projection;}
|
||||
const QTransform &transform() const {return _transform;}
|
||||
|
||||
const QString &name() const {return _name;}
|
||||
const QString &image() const {return _image;}
|
||||
const QSize &size() const {return _size;}
|
||||
|
||||
private:
|
||||
struct CalibrationPoint {
|
||||
ReferencePoint rp;
|
||||
Coordinates ll;
|
||||
int zone;
|
||||
};
|
||||
|
||||
int parse(QIODevice &device, QList<CalibrationPoint> &points,
|
||||
QString &projection, Projection::Setup &setup, QString &datum);
|
||||
bool parseMapFile(QIODevice &device, QList<CalibrationPoint> &points,
|
||||
QString &projection, Projection::Setup &setup, QString &datum);
|
||||
const GCS *createGCS(const QString &datum);
|
||||
bool createProjection(const GCS *gcs, const QString &projection,
|
||||
const Projection::Setup &setup, QList<CalibrationPoint> &points);
|
||||
bool computeTransformation(QList<CalibrationPoint> &points);
|
||||
|
||||
QString _name;
|
||||
QString _image;
|
||||
QSize _size;
|
||||
|
||||
Projection _projection;
|
||||
QTransform _transform;
|
||||
|
||||
QString _errorString;
|
||||
};
|
||||
|
||||
#endif // MAPFILE_H
|
@ -4,147 +4,140 @@
|
||||
#include "atlas.h"
|
||||
#include "offlinemap.h"
|
||||
#include "onlinemap.h"
|
||||
#include "mapsource.h"
|
||||
#include "maplist.h"
|
||||
|
||||
|
||||
#define ZOOM_MAX 18
|
||||
#define ZOOM_MIN 2
|
||||
|
||||
Map *MapList::loadListEntry(const QByteArray &line)
|
||||
bool MapList::loadSource(const QString &path, bool dir)
|
||||
{
|
||||
int max;
|
||||
MapSource ms;
|
||||
Map *map;
|
||||
|
||||
QList<QByteArray> list = line.split('\t');
|
||||
if (list.size() < 2)
|
||||
return 0;
|
||||
|
||||
QByteArray ba1 = list.at(0).trimmed();
|
||||
QByteArray ba2 = list.at(1).trimmed();
|
||||
if (ba1.isEmpty() || ba2.isEmpty())
|
||||
return 0;
|
||||
|
||||
if (list.size() == 3) {
|
||||
bool ok;
|
||||
max = QString(list.at(2).trimmed()).toInt(&ok);
|
||||
if (!ok)
|
||||
return 0;
|
||||
} else
|
||||
max = ZOOM_MAX;
|
||||
|
||||
return new OnlineMap(QString::fromUtf8(ba1.data(), ba1.size()),
|
||||
QString::fromLatin1(ba2.data(), ba2.size()), Range(ZOOM_MIN, max), this);
|
||||
}
|
||||
|
||||
bool MapList::loadList(const QString &path)
|
||||
{
|
||||
QFile file(path);
|
||||
QList<Map*> maps;
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
_errorString = file.errorString();
|
||||
if (!ms.loadFile(path, &map)) {
|
||||
if (dir)
|
||||
_errorString += path + ": " + ms.errorString() + "\n";
|
||||
else
|
||||
_errorString = ms.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
int ln = 0;
|
||||
while (!file.atEnd()) {
|
||||
ln++;
|
||||
QByteArray line = file.readLine();
|
||||
Map *map = loadListEntry(line);
|
||||
|
||||
if (map)
|
||||
maps.append(map);
|
||||
else {
|
||||
for (int i = 0; i < maps.count(); i++)
|
||||
delete maps.at(i);
|
||||
_errorString = QString("Invalid map list entry on line %1.")
|
||||
.arg(QString::number(ln));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_maps += maps;
|
||||
map->setParent(this);
|
||||
_maps.append(map);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MapList::loadMap(const QString &path)
|
||||
bool MapList::loadMap(const QString &path, bool dir)
|
||||
{
|
||||
OfflineMap *map = new OfflineMap(path, this);
|
||||
|
||||
if (map->isValid()) {
|
||||
_maps.append(map);
|
||||
return true;
|
||||
} else {
|
||||
if (dir)
|
||||
_errorString += path + ": " + map->errorString() + "\n";
|
||||
else
|
||||
_errorString = map->errorString();
|
||||
delete map;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool MapList::loadTba(const QString &path)
|
||||
bool MapList::loadAtlas(const QString &path, bool dir)
|
||||
{
|
||||
Atlas *atlas = new Atlas(path, this);
|
||||
|
||||
if (atlas->isValid()) {
|
||||
_maps.append(atlas);
|
||||
return true;
|
||||
} else {
|
||||
if (dir)
|
||||
_errorString += path + ": " + atlas->errorString() + "\n";
|
||||
else
|
||||
_errorString = atlas->errorString();
|
||||
delete atlas;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool MapList::loadTar(const QString &path)
|
||||
{
|
||||
Atlas *atlas = new Atlas(path, this);
|
||||
if (atlas->isValid()) {
|
||||
_maps.append(atlas);
|
||||
return true;
|
||||
} else {
|
||||
_errorString = atlas->errorString();
|
||||
delete atlas;
|
||||
OfflineMap *map = new OfflineMap(path, this);
|
||||
if (map->isValid()) {
|
||||
_maps.append(map);
|
||||
return true;
|
||||
} else {
|
||||
qWarning("%s: %s", qPrintable(path), qPrintable(_errorString));
|
||||
qWarning("%s: %s", qPrintable(path),
|
||||
qPrintable(map->errorString()));
|
||||
_errorString = "Not a map/atlas file";
|
||||
delete map;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MapList::loadFile(const QString &path)
|
||||
bool MapList::loadFile(const QString &path, bool *atlas, bool dir)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
QString suffix = fi.suffix().toLower();
|
||||
|
||||
if (suffix == "txt")
|
||||
return loadList(path);
|
||||
else if (suffix == "map")
|
||||
return loadMap(path);
|
||||
else if (suffix == "tba")
|
||||
return loadTba(path);
|
||||
else if (suffix == "tar")
|
||||
return loadTar(path);
|
||||
else {
|
||||
_errorString = "Not a map/atlas file";
|
||||
return false;
|
||||
if (Atlas::isAtlas(path)) {
|
||||
*atlas = true;
|
||||
return loadAtlas(path, dir);
|
||||
} else if (suffix == "xml") {
|
||||
*atlas = false;
|
||||
return loadSource(path, dir);
|
||||
} else {
|
||||
*atlas = false;
|
||||
return loadMap(path, dir);
|
||||
}
|
||||
}
|
||||
|
||||
bool MapList::loadDirR(const QString &path)
|
||||
{
|
||||
QDir md(path);
|
||||
md.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
md.setSorting(QDir::DirsLast);
|
||||
QFileInfoList ml = md.entryInfoList();
|
||||
bool atlas, ret = true;
|
||||
|
||||
for (int i = 0; i < ml.size(); i++) {
|
||||
const QFileInfo &fi = ml.at(i);
|
||||
QString suffix = fi.suffix().toLower();
|
||||
|
||||
if (fi.isDir() && fi.fileName() != "set") {
|
||||
if (!loadDirR(fi.absoluteFilePath()))
|
||||
ret = false;
|
||||
} else if (filter().contains("*." + suffix)) {
|
||||
if (!loadFile(fi.absoluteFilePath(), &atlas, true))
|
||||
ret = false;
|
||||
if (atlas)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool MapList::loadFile(const QString &path)
|
||||
{
|
||||
bool atlas;
|
||||
|
||||
_errorString.clear();
|
||||
return loadFile(path, &atlas, false);
|
||||
}
|
||||
|
||||
bool MapList::loadDir(const QString &path)
|
||||
{
|
||||
_errorString.clear();
|
||||
return loadDirR(path);
|
||||
}
|
||||
|
||||
void MapList::clear()
|
||||
{
|
||||
for (int i = 0; i < _maps.count(); i++)
|
||||
delete _maps.at(i);
|
||||
_maps.clear();
|
||||
}
|
||||
|
||||
QString MapList::formats()
|
||||
{
|
||||
return tr("Map files (*.map *.tba *.tar)") + ";;"
|
||||
+ tr("URL list files (*.txt)");
|
||||
return
|
||||
tr("Supported files") + " (*.map *.tar *.tba *.tif *.tiff *.xml);;"
|
||||
+ tr("OziExplorer maps") + " (*.map);;"
|
||||
+ tr("TrekBuddy maps/atlases") + " (*.tar *.tba);;"
|
||||
+ tr("GeoTIFF images") + " (*.tif *.tiff);;"
|
||||
+ tr("Online map sources") + " (*.xml)";
|
||||
}
|
||||
|
||||
QStringList MapList::filter()
|
||||
{
|
||||
QStringList filter;
|
||||
filter << "*.map" << "*.tba" << "*.tar" << "*.txt";
|
||||
filter << "*.map" << "*.tba" << "*.tar" << "*.xml" << "*.tif" << "*.tiff";
|
||||
return filter;
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <QString>
|
||||
#include "map.h"
|
||||
|
||||
class Tar;
|
||||
|
||||
class MapList : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -13,6 +15,8 @@ public:
|
||||
MapList(QObject *parent = 0) : QObject(parent) {}
|
||||
|
||||
bool loadFile(const QString &path);
|
||||
bool loadDir(const QString &path);
|
||||
void clear();
|
||||
|
||||
const QList<Map*> &maps() const {return _maps;}
|
||||
const QString &errorString() const {return _errorString;}
|
||||
@ -21,12 +25,14 @@ public:
|
||||
static QStringList filter();
|
||||
|
||||
private:
|
||||
bool loadFile(const QString &path, bool *atlas, bool dir);
|
||||
bool loadDirR(const QString &path);
|
||||
|
||||
Map *loadListEntry(const QByteArray &line);
|
||||
|
||||
bool loadList(const QString &path);
|
||||
bool loadMap(const QString &path);
|
||||
bool loadTba(const QString &path);
|
||||
bool loadTar(const QString &path);
|
||||
bool loadSource(const QString &path, bool dir);
|
||||
bool loadMap(const QString &path, bool dir);
|
||||
bool loadAtlas(const QString &path, bool dir);
|
||||
|
||||
QList<Map*> _maps;
|
||||
QString _errorString;
|
||||
|
172
src/map/mapsource.cpp
Normal file
172
src/map/mapsource.cpp
Normal file
@ -0,0 +1,172 @@
|
||||
#include <QFile>
|
||||
#include <QXmlStreamReader>
|
||||
#include "onlinemap.h"
|
||||
#include "mapsource.h"
|
||||
|
||||
|
||||
#define ZOOM_MAX 19
|
||||
#define ZOOM_MIN 0
|
||||
#define BOUNDS_LEFT -180
|
||||
#define BOUNDS_TOP 85.0511
|
||||
#define BOUNDS_RIGHT 180
|
||||
#define BOUNDS_BOTTOM -85.0511
|
||||
|
||||
Range MapSource::zooms(QXmlStreamReader &reader)
|
||||
{
|
||||
const QXmlStreamAttributes &attr = reader.attributes();
|
||||
int min, max;
|
||||
bool res;
|
||||
|
||||
if (attr.hasAttribute("min")) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
min = attr.value("min").toString().toInt(&res);
|
||||
#else // QT_VERSION < 5
|
||||
min = attr.value("min").toInt(&res);
|
||||
#endif // QT_VERSION < 5
|
||||
if (!res || (min < ZOOM_MIN || min > ZOOM_MAX)) {
|
||||
reader.raiseError("Invalid minimal zoom level");
|
||||
return Range();
|
||||
}
|
||||
} else
|
||||
min = ZOOM_MIN;
|
||||
|
||||
if (attr.hasAttribute("max")) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
max = attr.value("max").toString().toInt(&res);
|
||||
#else // QT_VERSION < 5
|
||||
max = attr.value("max").toInt(&res);
|
||||
#endif // QT_VERSION < 5
|
||||
if (!res || (max < ZOOM_MIN || max > ZOOM_MAX)) {
|
||||
reader.raiseError("Invalid maximal zoom level");
|
||||
return Range();
|
||||
}
|
||||
} else
|
||||
max = ZOOM_MAX;
|
||||
|
||||
if (min > max || max < min) {
|
||||
reader.raiseError("Invalid maximal/minimal zoom level combination");
|
||||
return Range();
|
||||
}
|
||||
|
||||
return Range(min, max);
|
||||
}
|
||||
|
||||
RectC MapSource::bounds(QXmlStreamReader &reader)
|
||||
{
|
||||
const QXmlStreamAttributes &attr = reader.attributes();
|
||||
double top, left, bottom, right;
|
||||
bool res;
|
||||
|
||||
if (attr.hasAttribute("top")) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
top = attr.value("top").toString().toDouble(&res);
|
||||
#else // QT_VERSION < 5
|
||||
top = attr.value("top").toDouble(&res);
|
||||
#endif // QT_VERSION < 5
|
||||
if (!res || (top < BOUNDS_BOTTOM || top > BOUNDS_TOP)) {
|
||||
reader.raiseError("Invalid bounds top value");
|
||||
return RectC();
|
||||
}
|
||||
} else
|
||||
top = BOUNDS_TOP;
|
||||
|
||||
if (attr.hasAttribute("bottom")) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
bottom = attr.value("bottom").toString().toDouble(&res);
|
||||
#else // QT_VERSION < 5
|
||||
bottom = attr.value("bottom").toDouble(&res);
|
||||
#endif // QT_VERSION < 5
|
||||
if (!res || (bottom < BOUNDS_BOTTOM || bottom > BOUNDS_TOP)) {
|
||||
reader.raiseError("Invalid bounds bottom value");
|
||||
return RectC();
|
||||
}
|
||||
} else
|
||||
bottom = BOUNDS_BOTTOM;
|
||||
|
||||
if (attr.hasAttribute("left")) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
left = attr.value("left").toString().toDouble(&res);
|
||||
#else // QT_VERSION < 5
|
||||
left = attr.value("left").toDouble(&res);
|
||||
#endif // QT_VERSION < 5
|
||||
if (!res || (left < BOUNDS_LEFT || left > BOUNDS_RIGHT)) {
|
||||
reader.raiseError("Invalid bounds left value");
|
||||
return RectC();
|
||||
}
|
||||
} else
|
||||
left = BOUNDS_LEFT;
|
||||
|
||||
if (attr.hasAttribute("right")) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
right = attr.value("right").toString().toDouble(&res);
|
||||
#else // QT_VERSION < 5
|
||||
right = attr.value("right").toDouble(&res);
|
||||
#endif // QT_VERSION < 5
|
||||
if (!res || (right < BOUNDS_LEFT || right > BOUNDS_RIGHT)) {
|
||||
reader.raiseError("Invalid bounds right value");
|
||||
return RectC();
|
||||
}
|
||||
} else
|
||||
right = BOUNDS_RIGHT;
|
||||
|
||||
if (bottom > top || top < bottom) {
|
||||
reader.raiseError("Invalid bottom/top bounds combination");
|
||||
return RectC();
|
||||
}
|
||||
if (left > right || right < left) {
|
||||
reader.raiseError("Invalid left/right bounds combination");
|
||||
return RectC();
|
||||
}
|
||||
|
||||
return RectC(Coordinates(left, top), Coordinates(right, bottom));
|
||||
}
|
||||
|
||||
void MapSource::map(QXmlStreamReader &reader, Map **map)
|
||||
{
|
||||
QString name, url;
|
||||
Range z(ZOOM_MIN, ZOOM_MAX);
|
||||
RectC b(Coordinates(BOUNDS_LEFT, BOUNDS_TOP),
|
||||
Coordinates(BOUNDS_RIGHT, BOUNDS_BOTTOM));
|
||||
|
||||
while (reader.readNextStartElement()) {
|
||||
if (reader.name() == "name")
|
||||
name = reader.readElementText();
|
||||
else if (reader.name() == "url")
|
||||
url = reader.readElementText();
|
||||
else if (reader.name() == "zoom") {
|
||||
z = zooms(reader);
|
||||
reader.skipCurrentElement();
|
||||
} else if (reader.name() == "bounds") {
|
||||
b = bounds(reader);
|
||||
reader.skipCurrentElement();
|
||||
} else
|
||||
reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
*map = reader.error() ? 0 : new OnlineMap(name, url, z, b);
|
||||
}
|
||||
|
||||
bool MapSource::loadFile(const QString &path, Map **map)
|
||||
{
|
||||
QFile file(path);
|
||||
QXmlStreamReader reader;
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
_errorString = file.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
reader.setDevice(&file);
|
||||
|
||||
if (reader.readNextStartElement()) {
|
||||
if (reader.name() == "map")
|
||||
MapSource::map(reader, map);
|
||||
else
|
||||
reader.raiseError("Not an online map source file");
|
||||
}
|
||||
|
||||
_errorString = reader.error() ? QString("%1: %2").arg(reader.lineNumber())
|
||||
.arg(reader.errorString()) : QString();
|
||||
|
||||
return !reader.error();
|
||||
}
|
25
src/map/mapsource.h
Normal file
25
src/map/mapsource.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef MAPSOURCE_H
|
||||
#define MAPSOURCE_H
|
||||
|
||||
#include <QList>
|
||||
#include "common/range.h"
|
||||
#include "common/rectc.h"
|
||||
|
||||
class Map;
|
||||
class QXmlStreamReader;
|
||||
|
||||
class MapSource
|
||||
{
|
||||
public:
|
||||
bool loadFile(const QString &path, Map **map);
|
||||
const QString &errorString() const {return _errorString;}
|
||||
|
||||
private:
|
||||
RectC bounds(QXmlStreamReader &reader);
|
||||
Range zooms(QXmlStreamReader &reader);
|
||||
void map(QXmlStreamReader &reader, Map **map);
|
||||
|
||||
QString _errorString;
|
||||
};
|
||||
|
||||
#endif // MAPSOURCE_H
|
@ -1,11 +1,13 @@
|
||||
#ifndef MERCATOR_H
|
||||
#define MERCATOR_H
|
||||
|
||||
#include "projection.h"
|
||||
#include "ct.h"
|
||||
|
||||
class Mercator : public Projection
|
||||
class Mercator : public CT
|
||||
{
|
||||
public:
|
||||
virtual CT *clone() const {return new Mercator(*this);}
|
||||
|
||||
virtual QPointF ll2xy(const Coordinates &c) const;
|
||||
virtual Coordinates xy2ll(const QPointF &p) const;
|
||||
};
|
||||
|
@ -1,7 +0,0 @@
|
||||
#include <QRectF>
|
||||
|
||||
inline QRectF scaled(const QRectF &rect, qreal factor)
|
||||
{
|
||||
return QRectF(QPointF(rect.left() * factor, rect.top() * factor),
|
||||
QSizeF(rect.width() * factor, rect.height() * factor));
|
||||
}
|
@ -9,297 +9,20 @@
|
||||
#include <QPixmapCache>
|
||||
#include "common/coordinates.h"
|
||||
#include "common/rectc.h"
|
||||
#include "datum.h"
|
||||
#include "utm.h"
|
||||
#include "matrix.h"
|
||||
#include "ozf.h"
|
||||
#include "mapfile.h"
|
||||
#include "geotiff.h"
|
||||
#include "offlinemap.h"
|
||||
|
||||
|
||||
int OfflineMap::parse(QIODevice &device, QList<ReferencePoint> &points,
|
||||
QString &projection, Projection::Setup &setup, QString &datum)
|
||||
void OfflineMap::computeResolution()
|
||||
{
|
||||
bool res;
|
||||
int ln = 1;
|
||||
Coordinates tl = xy2ll((bounds().topLeft()));
|
||||
Coordinates br = xy2ll(bounds().bottomRight());
|
||||
|
||||
while (!device.atEnd()) {
|
||||
QByteArray line = device.readLine();
|
||||
qreal ds = tl.distanceTo(br);
|
||||
qreal ps = QLineF(bounds().topLeft(), bounds().bottomRight()).length();
|
||||
|
||||
if (ln == 1) {
|
||||
if (!line.trimmed().startsWith("OziExplorer Map Data File"))
|
||||
return ln;
|
||||
} else if (ln == 2)
|
||||
_name = line.trimmed();
|
||||
else if (ln == 3)
|
||||
_imgPath = line.trimmed();
|
||||
else if (ln == 5)
|
||||
datum = line.split(',').at(0).trimmed();
|
||||
else {
|
||||
QList<QByteArray> list = line.split(',');
|
||||
QString key(list.at(0).trimmed());
|
||||
bool ll = true; bool pp = true;
|
||||
|
||||
if (key.startsWith("Point") && list.count() == 17
|
||||
&& !list.at(2).trimmed().isEmpty()) {
|
||||
int x = list.at(2).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
return ln;
|
||||
int y = list.at(3).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
return ln;
|
||||
|
||||
int latd = list.at(6).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
qreal latm = list.at(7).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
int lond = list.at(9).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
qreal lonm = list.at(10).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
if (ll && list.at(8).trimmed() == "S") {
|
||||
latd = -latd;
|
||||
latm = -latm;
|
||||
}
|
||||
if (ll && list.at(11).trimmed() == "W") {
|
||||
lond = -lond;
|
||||
lonm = -lonm;
|
||||
}
|
||||
|
||||
setup.zone = list.at(13).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
setup.zone = 0;
|
||||
qreal ppx = list.at(14).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
pp = false;
|
||||
qreal ppy = list.at(15).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
pp = false;
|
||||
if (list.at(16).trimmed() == "S")
|
||||
setup.zone = -setup.zone;
|
||||
|
||||
ReferencePoint p;
|
||||
p.xy = QPoint(x, y);
|
||||
if (ll) {
|
||||
p.ll = Coordinates(lond + lonm/60.0, latd + latm/60.0);
|
||||
if (p.ll.isValid())
|
||||
points.append(p);
|
||||
else
|
||||
return ln;
|
||||
} else if (pp) {
|
||||
p.pp = QPointF(ppx, ppy);
|
||||
points.append(p);
|
||||
} else
|
||||
return ln;
|
||||
} else if (key == "IWH") {
|
||||
if (list.count() < 4)
|
||||
return ln;
|
||||
int w = list.at(2).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
return ln;
|
||||
int h = list.at(3).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
return ln;
|
||||
_size = QSize(w, h);
|
||||
} else if (key == "Map Projection") {
|
||||
if (list.count() < 2)
|
||||
return ln;
|
||||
projection = list.at(1);
|
||||
} else if (key == "Projection Setup") {
|
||||
if (list.count() < 8)
|
||||
return ln;
|
||||
setup.latitudeOrigin = list.at(1).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.latitudeOrigin = 0;
|
||||
setup.longitudeOrigin = list.at(2).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.longitudeOrigin = 0;
|
||||
setup.scale = list.at(3).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.scale = 1.0;
|
||||
setup.falseEasting = list.at(4).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.falseEasting = 0;
|
||||
setup.falseNorthing = list.at(5).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.falseNorthing = 0;
|
||||
setup.standardParallel1 = list.at(6).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.standardParallel1 = 0;
|
||||
setup.standardParallel2 = list.at(7).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.standardParallel2 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ln++;
|
||||
}
|
||||
|
||||
if (!setup.zone && !points.first().ll.isNull())
|
||||
setup.zone = UTM::zone(points.first().ll);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool OfflineMap::parseMapFile(QIODevice &device, QList<ReferencePoint> &points,
|
||||
QString &projection, Projection::Setup &setup, QString &datum)
|
||||
{
|
||||
int el;
|
||||
|
||||
if (!device.open(QIODevice::ReadOnly)) {
|
||||
_errorString = QString("Error opening map file: %1")
|
||||
.arg(device.errorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((el = parse(device, points, projection, setup, datum))) {
|
||||
_errorString = QString("Map file parse error on line %1").arg(el);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OfflineMap::createProjection(const QString &datum,
|
||||
const QString &projection, const Projection::Setup &setup,
|
||||
QList<ReferencePoint> &points)
|
||||
{
|
||||
if (points.count() < 2) {
|
||||
_errorString = "Insufficient number of reference points";
|
||||
return false;
|
||||
}
|
||||
|
||||
Datum d = Datum::datum(datum);
|
||||
if (d.isNull()) {
|
||||
_errorString = QString("%1: Unknown datum").arg(datum);
|
||||
return false;
|
||||
}
|
||||
|
||||
_projection = Projection::projection(projection, d.ellipsoid(), setup);
|
||||
if (!_projection) {
|
||||
_errorString = Projection::errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
if (points.at(i).ll.isNull())
|
||||
points[i].ll = d.toWGS84(_projection->xy2ll(points.at(i).pp));
|
||||
else
|
||||
points[i].ll = d.toWGS84(points[i].ll);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OfflineMap::simpleTransformation(const QList<ReferencePoint> &points)
|
||||
{
|
||||
if (points.at(0).xy.x() == points.at(1).xy.x()
|
||||
|| points.at(0).xy.y() == points.at(1).xy.y()) {
|
||||
_errorString = "Invalid reference points tuple";
|
||||
return false;
|
||||
}
|
||||
|
||||
QPointF p0(_projection->ll2xy(points.at(0).ll));
|
||||
QPointF p1(_projection->ll2xy(points.at(1).ll));
|
||||
|
||||
qreal dX, dY, lat0, lon0;
|
||||
dX = (p0.x() - p1.x()) / (points.at(0).xy.x() - points.at(1).xy.x());
|
||||
dY = (p1.y() - p0.y()) / (points.at(1).xy.y() - points.at(0).xy.y());
|
||||
lat0 = p0.y() - points.at(0).xy.y() * dY;
|
||||
lon0 = p1.x() - points.at(1).xy.x() * dX;
|
||||
|
||||
_transform = QTransform(1.0/dX, 0, 0, 1.0/dY, -lon0/dX, -lat0/dY);
|
||||
_inverted = _transform.inverted();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OfflineMap::affineTransformation(const QList<ReferencePoint> &points)
|
||||
{
|
||||
Matrix c(3, 2);
|
||||
c.zeroize();
|
||||
for (size_t i = 0; i < c.h(); i++) {
|
||||
for (size_t j = 0; j < c.w(); j++) {
|
||||
for (int k = 0; k < points.size(); k++) {
|
||||
double f[3], t[2];
|
||||
QPointF p = _projection->ll2xy(points.at(k).ll);
|
||||
|
||||
f[0] = p.x();
|
||||
f[1] = p.y();
|
||||
f[2] = 1.0;
|
||||
t[0] = points.at(k).xy.x();
|
||||
t[1] = points.at(k).xy.y();
|
||||
c.m(i,j) += f[i] * t[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Matrix Q(3, 3);
|
||||
Q.zeroize();
|
||||
for (int qi = 0; qi < points.size(); qi++) {
|
||||
double v[3];
|
||||
QPointF p = _projection->ll2xy(points.at(qi).ll);
|
||||
|
||||
v[0] = p.x();
|
||||
v[1] = p.y();
|
||||
v[2] = 1.0;
|
||||
for (size_t i = 0; i < Q.h(); i++)
|
||||
for (size_t j = 0; j < Q.w(); j++)
|
||||
Q.m(i,j) += v[i] * v[j];
|
||||
}
|
||||
|
||||
Matrix M = Q.augemented(c);
|
||||
if (!M.eliminate()) {
|
||||
_errorString = "Singular transformation matrix";
|
||||
return false;
|
||||
}
|
||||
|
||||
_transform = QTransform(M.m(0,3), M.m(0,4), M.m(1,3), M.m(1,4), M.m(2,3),
|
||||
M.m(2,4));
|
||||
_inverted = _transform.inverted();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OfflineMap::computeTransformation(const QList<ReferencePoint> &points)
|
||||
{
|
||||
Q_ASSERT(points.size() >= 2);
|
||||
|
||||
if (points.size() == 2)
|
||||
return simpleTransformation(points);
|
||||
else
|
||||
return affineTransformation(points);
|
||||
}
|
||||
|
||||
bool OfflineMap::computeResolution(QList<ReferencePoint> &points)
|
||||
{
|
||||
Q_ASSERT(points.count() >= 2);
|
||||
|
||||
int maxLon = 0, minLon = 0, maxLat = 0, minLat = 0;
|
||||
qreal dLon, pLon, dLat, pLat;
|
||||
|
||||
for (int i = 1; i < points.size(); i++) {
|
||||
if (points.at(i).ll.lon() < points.at(minLon).ll.lon())
|
||||
minLon = i;
|
||||
if (points.at(i).ll.lon() > points.at(maxLon).ll.lon())
|
||||
maxLon = i;
|
||||
if (points.at(i).ll.lat() < points.at(minLat).ll.lat())
|
||||
minLat = i;
|
||||
if (points.at(i).ll.lat() > points.at(maxLat).ll.lat())
|
||||
maxLat = i;
|
||||
}
|
||||
|
||||
dLon = points.at(minLon).ll.distanceTo(points.at(maxLon).ll);
|
||||
pLon = QLineF(points.at(minLon).xy, points.at(maxLon).xy).length();
|
||||
dLat = points.at(minLat).ll.distanceTo(points.at(maxLat).ll);
|
||||
pLat = QLineF(points.at(minLat).xy, points.at(maxLat).xy).length();
|
||||
|
||||
_resolution = (dLon/pLon + dLat/pLat) / 2.0;
|
||||
|
||||
return true;
|
||||
_resolution = ds/ps;
|
||||
}
|
||||
|
||||
bool OfflineMap::getImageInfo(const QString &path)
|
||||
@ -384,16 +107,11 @@ bool OfflineMap::totalSizeSet()
|
||||
OfflineMap::OfflineMap(const QString &fileName, QObject *parent)
|
||||
: Map(parent)
|
||||
{
|
||||
QList<ReferencePoint> points;
|
||||
QString proj, datum;
|
||||
Projection::Setup setup;
|
||||
QFileInfo fi(fileName);
|
||||
QString suffix = fi.suffix().toLower();
|
||||
|
||||
|
||||
_valid = false;
|
||||
_img = 0;
|
||||
_projection = 0;
|
||||
_resolution = 0.0;
|
||||
_zoom = 0;
|
||||
_scale = QPointF(1.0, 1.0);
|
||||
@ -411,23 +129,46 @@ OfflineMap::OfflineMap(const QString &fileName, QObject *parent)
|
||||
return;
|
||||
}
|
||||
QBuffer mapFile(&ba);
|
||||
if (!parseMapFile(mapFile, points, proj, setup, datum))
|
||||
MapFile mf;
|
||||
if (!mf.load(mapFile)) {
|
||||
_errorString = mf.errorString();
|
||||
return;
|
||||
} else if (suffix =="map") {
|
||||
} else {
|
||||
_name = mf.name();
|
||||
_size = mf.size();
|
||||
_imgPath = mf.image();
|
||||
_projection = mf.projection();
|
||||
_transform = mf.transform();
|
||||
}
|
||||
} else if (suffix == "map") {
|
||||
MapFile mf;
|
||||
QFile mapFile(fileName);
|
||||
if (!parseMapFile(mapFile, points, proj, setup, datum))
|
||||
if (!mf.load(mapFile)) {
|
||||
_errorString = mf.errorString();
|
||||
return;
|
||||
} else {
|
||||
_name = mf.name();
|
||||
_size = mf.size();
|
||||
_imgPath = mf.image();
|
||||
_projection = mf.projection();
|
||||
_transform = mf.transform();
|
||||
}
|
||||
} else if (suffix == "tif" || suffix == "tiff") {
|
||||
GeoTIFF gt;
|
||||
if (!gt.load(fileName)) {
|
||||
_errorString = gt.errorString();
|
||||
return;
|
||||
} else {
|
||||
_name = fi.fileName();
|
||||
_imgPath = fileName;
|
||||
_projection = gt.projection();
|
||||
_transform = gt.transform();
|
||||
}
|
||||
} else {
|
||||
_errorString = "Not a map file";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!createProjection(datum, proj, setup, points))
|
||||
return;
|
||||
if (!computeTransformation(points))
|
||||
return;
|
||||
computeResolution(points);
|
||||
|
||||
if (_tar.isOpen()) {
|
||||
if (!totalSizeSet())
|
||||
return;
|
||||
@ -448,20 +189,20 @@ OfflineMap::OfflineMap(const QString &fileName, QObject *parent)
|
||||
}
|
||||
}
|
||||
|
||||
_inverted = _transform.inverted();
|
||||
computeResolution();
|
||||
|
||||
_valid = true;
|
||||
}
|
||||
|
||||
OfflineMap::OfflineMap(const QString &fileName, Tar &tar, QObject *parent)
|
||||
: Map(parent)
|
||||
{
|
||||
QList<ReferencePoint> points;
|
||||
QString proj, datum;
|
||||
Projection::Setup setup;
|
||||
QFileInfo fi(fileName);
|
||||
MapFile mf;
|
||||
|
||||
_valid = false;
|
||||
_img = 0;
|
||||
_projection = 0;
|
||||
_resolution = 0.0;
|
||||
_zoom = 0;
|
||||
_scale = QPointF(1.0, 1.0);
|
||||
@ -477,28 +218,26 @@ OfflineMap::OfflineMap(const QString &fileName, Tar &tar, QObject *parent)
|
||||
}
|
||||
QBuffer buffer(&ba);
|
||||
|
||||
if (!parseMapFile(buffer, points, proj, setup, datum))
|
||||
if (!mf.load(buffer)) {
|
||||
_errorString = mf.errorString();
|
||||
return;
|
||||
if (!createProjection(datum, proj, setup, points))
|
||||
return;
|
||||
if (!totalSizeSet())
|
||||
return;
|
||||
if (!computeTransformation(points))
|
||||
return;
|
||||
computeResolution(points);
|
||||
}
|
||||
|
||||
_name = mf.name();
|
||||
_size = mf.size();
|
||||
_projection = mf.projection();
|
||||
_transform = mf.transform();
|
||||
|
||||
_inverted = _transform.inverted();
|
||||
computeResolution();
|
||||
|
||||
_tarPath = fi.absolutePath() + "/" + fi.completeBaseName() + ".tar";
|
||||
_imgPath = QString();
|
||||
_valid = true;
|
||||
}
|
||||
|
||||
OfflineMap::~OfflineMap()
|
||||
{
|
||||
if (_img)
|
||||
delete _img;
|
||||
if (_projection)
|
||||
delete _projection;
|
||||
}
|
||||
|
||||
void OfflineMap::load()
|
||||
@ -522,10 +261,8 @@ void OfflineMap::load()
|
||||
|
||||
void OfflineMap::unload()
|
||||
{
|
||||
if (_img) {
|
||||
delete _img;
|
||||
_img = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void OfflineMap::drawTiled(QPainter *painter, const QRectF &rect)
|
||||
@ -599,13 +336,9 @@ void OfflineMap::drawOZF(QPainter *painter, const QRectF &rect)
|
||||
|
||||
void OfflineMap::drawImage(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if (!_img || _img->isNull())
|
||||
painter->fillRect(rect, _backgroundColor);
|
||||
else {
|
||||
QRect r(rect.toRect());
|
||||
painter->drawImage(r.left(), r.top(), *_img, r.left(), r.top(),
|
||||
r.width(), r.height());
|
||||
}
|
||||
}
|
||||
|
||||
void OfflineMap::draw(QPainter *painter, const QRectF &rect)
|
||||
@ -614,26 +347,28 @@ void OfflineMap::draw(QPainter *painter, const QRectF &rect)
|
||||
drawOZF(painter, rect);
|
||||
else if (_tileSize.isValid())
|
||||
drawTiled(painter, rect);
|
||||
else
|
||||
else if (_img && !_img->isNull())
|
||||
drawImage(painter, rect);
|
||||
else
|
||||
painter->fillRect(rect, _backgroundColor);
|
||||
}
|
||||
|
||||
QPointF OfflineMap::ll2xy(const Coordinates &c)
|
||||
{
|
||||
if (_ozf.isOpen()) {
|
||||
QPointF p(_transform.map(_projection->ll2xy(c)));
|
||||
QPointF p(_transform.map(_projection.ll2xy(c)));
|
||||
return QPointF(p.x() * _scale.x(), p.y() * _scale.y());
|
||||
} else
|
||||
return _transform.map(_projection->ll2xy(c));
|
||||
return _transform.map(_projection.ll2xy(c));
|
||||
}
|
||||
|
||||
Coordinates OfflineMap::xy2ll(const QPointF &p)
|
||||
{
|
||||
if (_ozf.isOpen()) {
|
||||
return _projection->xy2ll(_inverted.map(QPointF(p.x() / _scale.x(),
|
||||
return _projection.xy2ll(_inverted.map(QPointF(p.x() / _scale.x(),
|
||||
p.y() / _scale.y())));
|
||||
} else
|
||||
return _projection->xy2ll(_inverted.map(p));
|
||||
return _projection.xy2ll(_inverted.map(p));
|
||||
}
|
||||
|
||||
QRectF OfflineMap::bounds() const
|
||||
@ -660,8 +395,8 @@ qreal OfflineMap::zoomFit(const QSize &size, const RectC &br)
|
||||
if (!br.isValid())
|
||||
rescale(0);
|
||||
else {
|
||||
QRect sbr(QRectF(_transform.map(_projection->ll2xy(br.topLeft())),
|
||||
_transform.map(_projection->ll2xy(br.bottomRight())))
|
||||
QRect sbr(QRectF(_transform.map(_projection.ll2xy(br.topLeft())),
|
||||
_transform.map(_projection.ll2xy(br.bottomRight())))
|
||||
.toRect().normalized());
|
||||
|
||||
for (int i = 0; i < _ozf.zooms(); i++) {
|
||||
|
@ -2,8 +2,9 @@
|
||||
#define OFFLINEMAP_H
|
||||
|
||||
#include <QTransform>
|
||||
#include "common/coordinates.h"
|
||||
#include "projection.h"
|
||||
#include "transform.h"
|
||||
#include "linearunits.h"
|
||||
#include "map.h"
|
||||
#include "tar.h"
|
||||
#include "ozf.h"
|
||||
@ -43,47 +44,28 @@ public:
|
||||
const QString &errorString() const {return _errorString;}
|
||||
|
||||
QPointF ll2pp(const Coordinates &c) const
|
||||
{return _projection->ll2xy(c);}
|
||||
{return _projection.ll2xy(c);}
|
||||
QPointF xy2pp(const QPointF &p) const
|
||||
{return _inverted.map(p);}
|
||||
QPointF pp2xy(const QPointF &p) const
|
||||
{return _transform.map(p);}
|
||||
|
||||
private:
|
||||
struct ReferencePoint {
|
||||
QPoint xy;
|
||||
Coordinates ll;
|
||||
QPointF pp;
|
||||
};
|
||||
|
||||
int parse(QIODevice &device, QList<ReferencePoint> &points,
|
||||
QString &projection, Projection::Setup &setup, QString &datum);
|
||||
bool parseMapFile(QIODevice &device, QList<ReferencePoint> &points,
|
||||
QString &projection, Projection::Setup &setup, QString &datum);
|
||||
bool totalSizeSet();
|
||||
bool createProjection(const QString &datum, const QString &projection,
|
||||
const Projection::Setup &setup, QList<ReferencePoint> &points);
|
||||
bool simpleTransformation(const QList<ReferencePoint> &points);
|
||||
bool affineTransformation(const QList<ReferencePoint> &points);
|
||||
bool computeTransformation(const QList<ReferencePoint> &points);
|
||||
bool computeResolution(QList<ReferencePoint> &points);
|
||||
bool getTileInfo(const QStringList &tiles, const QString &path = QString());
|
||||
bool getImageInfo(const QString &path);
|
||||
bool totalSizeSet();
|
||||
|
||||
void drawTiled(QPainter *painter, const QRectF &rect);
|
||||
void drawOZF(QPainter *painter, const QRectF &rect);
|
||||
void drawImage(QPainter *painter, const QRectF &rect);
|
||||
|
||||
void computeResolution();
|
||||
void rescale(int zoom);
|
||||
|
||||
QString _name;
|
||||
bool _valid;
|
||||
QString _errorString;
|
||||
|
||||
QSize _size;
|
||||
Projection *_projection;
|
||||
Projection _projection;
|
||||
QTransform _transform, _inverted;
|
||||
qreal _resolution;
|
||||
|
||||
OZF _ozf;
|
||||
Tar _tar;
|
||||
@ -92,9 +74,14 @@ private:
|
||||
QString _imgPath;
|
||||
QSize _tileSize;
|
||||
QString _tileName;
|
||||
QSize _size;
|
||||
|
||||
int _zoom;
|
||||
qreal _resolution;
|
||||
QPointF _scale;
|
||||
|
||||
bool _valid;
|
||||
QString _errorString;
|
||||
};
|
||||
|
||||
#endif // OFFLINEMAP_H
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "mercator.h"
|
||||
#include "downloader.h"
|
||||
#include "config.h"
|
||||
#include "misc.h"
|
||||
#include "onlinemap.h"
|
||||
|
||||
|
||||
@ -47,13 +46,11 @@ static bool loadTileFile(Tile &tile, const QString &file)
|
||||
Downloader *OnlineMap::downloader;
|
||||
|
||||
OnlineMap::OnlineMap(const QString &name, const QString &url,
|
||||
const Range &zooms, QObject *parent) : Map(parent)
|
||||
const Range &zooms, const RectC &bounds, QObject *parent)
|
||||
: Map(parent), _name(name), _url(url), _zooms(zooms), _bounds(bounds)
|
||||
{
|
||||
_name = name;
|
||||
_url = url;
|
||||
_block = false;
|
||||
_zooms = zooms;
|
||||
_zoom = zooms.max();
|
||||
_zoom = _zooms.max();
|
||||
|
||||
QString path = TILES_DIR + QString("/") + name;
|
||||
if (!QDir().mkpath(path))
|
||||
@ -168,8 +165,7 @@ void OnlineMap::clearCache()
|
||||
|
||||
QRectF OnlineMap::bounds() const
|
||||
{
|
||||
return scaled(QRectF(QPointF(-180, -180), QSizeF(360, 360)),
|
||||
1.0/zoom2scale(_zoom));
|
||||
return QRectF(ll2xy(_bounds.topLeft()), ll2xy(_bounds.bottomRight()));
|
||||
}
|
||||
|
||||
int OnlineMap::limitZoom(int zoom) const
|
||||
@ -253,14 +249,14 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect)
|
||||
}
|
||||
}
|
||||
|
||||
QPointF OnlineMap::ll2xy(const Coordinates &c)
|
||||
QPointF OnlineMap::ll2xy(const Coordinates &c) const
|
||||
{
|
||||
qreal scale = zoom2scale(_zoom);
|
||||
QPointF m = Mercator().ll2xy(c);
|
||||
return QPointF(m.x() / scale, m.y() / -scale);
|
||||
}
|
||||
|
||||
Coordinates OnlineMap::xy2ll(const QPointF &p)
|
||||
Coordinates OnlineMap::xy2ll(const QPointF &p) const
|
||||
{
|
||||
qreal scale = zoom2scale(_zoom);
|
||||
QPointF m(p.x() * scale, -p.y() * scale);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user